UseFetchJSONExample
src/prod/fetch/useFetchJSON.ts
import React from 'react'; export const useFetchJSON = (url: string) => { const [data, setData] = React.useState(null); React.useEffect(() => { fetch(url) .then(res => res.json()) .then(res => setData(res)); }, [url]); return [data]; };
dist/prod/fetch/useFetchJSON.js
import React from 'react'; export const useFetchJSON = (url) => { const [data, setData] = React.useState(null); React.useEffect(() => { fetch(url) .then(res => res.json()) .then(res => setData(res)); }, [url]); return [data]; };
src/prod/fetch/useFetchJSON.ts
import React from 'react'; export const useFetchJSON = (url: string) => { const [data, setData] = React.useState(null); React.useEffect(() => { fetch(url) .then(res => res.json()) .then(res => setData(res)); }, [url]); return [data]; };