Hacktoberfest

backstory

The Psychological Effects of useEffect

I live in Berlin

The land of sun and architecture

Gourmet Food

Conservative Nature

And the best airports

But we are not here to talk about airports

I WISH

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

Too easy tho

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

Is it confusing?

OMG YES

0
 Advanced issue found
 

Thank you

UseEffect

By Sara Vieira

UseEffect

  • 141