Question · JavaScript and React course · Module 5: useEffect and Custom Hooks

useEffect Hook - Basics

Which useEffect syntax will run the effect only once after the component mounts?

Answer options

  • useEffect(() => {...})
  • useEffect(() => {...}, [])
  • useEffect(() => {...}, [state])
  • useEffect(() => {...}, null)

You can check the correct answer by solving this task in the CodeWorlds game.