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
// https://ah-mahir.medium.com/stop-using-useeffect-2fb4dd3e0332 | |
import React from 'react'; | |
import { useQuery } from 'react-query'; | |
// The function that fetches the data | |
async function fetchData() { | |
const res = await fetch('https://api.example.com/data'); | |
if (!res.ok) { | |
throw new Error('Network response was not ok'); | |
} |