React/React Query
-
React Query 리액트 쿼리 사용법 사용하는 이유React/React Query 2023. 2. 28. 19:46
📌 기존의 코드는 다음과 같다. loading 이라는 값을 통해 데이터가 다 불러와졌는지를 판별한다. 그리고 데이터가 다 불러와졌다면 loading 을 false 값으로 전환하고 데이터를 setCoins 를 통해 coins 에 데이터를 담는다. 이러한 과정은 두개의 useState를 사용하게 만드는 단점이 존재한다. const [coins, setCoins] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { axios .get("https://api.coinpaprika.com/v1/tickers") .then((Response) => { setCoins(Response.data.slice(0, 99)); set..