DEV Community

Discussion on: 💡 React Hooks: async function in the useEffect

Collapse
 
elmehdiyessad profile image
elmehdi

Hey in order to get data once and prevent useEffect hook that render the data in the infinite loop you should just initialize an empty array as a second argument to the useEffect hook like this

useEffect(() => {
// use code here
}, [])