Hacktoberfest

backstory

The Psychological Effects of useEffect

Sara Vieira

Developer @

@NIKKITAFTW

Hooked yet?

0
 Advanced issue found
 

Remember component lifecycles?

  • componentDidMount()
  • shouldComponentUpdate()
  • componentDidUpdate()
  • componentWillUnmount()

There were a lot

BUT

Can you guess when componentDidUpdate ran?

When the component updated

Can you guess when useEffect runs?

EVERYWHERE

useEffect(() => {
	// Your magic
})
useEffect(() => {
	// Your magic
    
    return () => {
    	// Your clean up magic
    }
})
useEffect(() => {
	// Your magic
    
    return () => {
    	// Your clean up magic
    }
   // The dependencies array
}, [])

We have three things to play with

Thank you

Copy of UseEffect

By Sara Vieira

Copy of UseEffect

  • 216