Put in order · JavaScript and React course · Module 5: useEffect and Custom Hooks
Async Pattern in useEffect
Order the steps for correctly using async/await inside useEffect:
Items to put in order
- We save the result in state using setState
- fetchData calls await fetch(url) and processes the response
- Inside the callback we define async function fetchData()
- At the end of the callback we call fetchData()
- useEffect accepts a synchronous callback
You can check the correct answer by solving this task in the CodeWorlds game.