![]() ![]() UseEffect(callback,): Runs ONCE after initial rendering. UseEffect(callback) : Runs after EVERY rendering. With this hook you can actually control how many times or when you want the API request to run after initial rendering based on your dependencies argument. So where should you put the API request logic? Inside useEffect(callback, dependencies) hook. ![]() So obviously, your fetch API runs every time the App component re-renders, and you are updating the state inside your fetch API, which again causes your app to re-render again, runs fetch API again, changes state again, app re-renders and hence the too many requests error. If you do, the API request will run every time your component re-renders upon state changes. If(scription & element.urlToImage & element.title)įirst of all you must never do API requests directly inside your component. I recon this is causing too many request error when I am trying to use a legit api for fetching data it sends too many requests for some reason and causes 429 error how can i fix that return ( Const = useState() Ĭonst = useState(false) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |