custom hook실습
custom hook을 이용하여 useEffect 로직 분리하기 hook.js import { useEffect, useState } from "react"; const useFetchData = (fetchUrl) => { const [data, setData] = useState(); useEffect(() => { fetch(fetchUrl, { headers: { "Content-Type": "application/json", Accept: "application/json" } }) .then((response) => { return response.json(); }) .then((myJson) => { setData(myJson); }) .catch((error) => { console.log(..
codestates/section4
2023. 3. 23. 01:52