useFetch

UseFetchExample

src/prod/fetch/useFetch.ts

import React from 'react';



export const useFetch = (url: string) => {
	const [data, setData] = React.useState<string | null>(null);

	React.useEffect(() => {
		fetch(url)
			.then(res => res.text())
			.then(res => setData(res));
	}, [url]);

	return [data];
};

dist/prod/fetch/useFetch.js

import React from 'react';
export const useFetch = (url) => {
    const [data, setData] = React.useState(null);
    React.useEffect(() => {
        fetch(url)
            .then(res => res.text())
            .then(res => setData(res));
    }, [url]);
    return [data];
};

src/prod/fetch/useFetch.ts

import React from 'react';



export const useFetch = (url: string) => {
	const [data, setData] = React.useState<string | null>(null);

	React.useEffect(() => {
		fetch(url)
			.then(res => res.text())
			.then(res => setData(res));
	}, [url]);

	return [data];
};