-
-
Save Chryus/555ab59560b4ddf4f513787dd295c089 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dataFetcher.js | |
import { useState, useEffect } from "react"; | |
export default function dataFetcher(url) { | |
const [data, setData] = useState([]); | |
useEffect(() => { | |
fetch(url) | |
.then(response => response.json()) | |
.then(data => setData(data)); | |
}, []); | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment