Code React Sweetly
/
Effect Hooks
Effect Hooks
https://leanpub.com/code-react-sweetly
Types of Effects in React
https://leanpub.com/code-react-sweetly
How to Know the Effects That Require Cleanup
https://leanpub.com/code-react-sweetly
How to Know the Effects That Do Not Require Any Cleanup
https://leanpub.com/code-react-sweetly
How to Clean Up a Component’s Effects
https://leanpub.com/code-react-sweetly
When does React run the cleanup function?
https://leanpub.com/code-react-sweetly
Effect’s body vs Effect’s cleanup function
https://leanpub.com/code-react-sweetly
How to Specify When React Effects Should Run
https://leanpub.com/code-react-sweetly
Syntax of the Effect Hook
https://leanpub.com/code-react-sweetly
What is a reactive value in React?
https://leanpub.com/code-react-sweetly
Example of a non-reactive JavaScript function
https://leanpub.com/code-react-sweetly
Example of a reactive JavaScript function
https://leanpub.com/code-react-sweetly
When does React run an Effect?
https://leanpub.com/code-react-sweetly
How to run Effects on every render
https://leanpub.com/code-react-sweetly
How to run Effects only after a function component’s mounting
https://leanpub.com/code-react-sweetly
How to run Effects only on mount, and if the component’s reactive values change
https://leanpub.com/code-react-sweetly
What to know about the dependency array
https://leanpub.com/code-react-sweetly
Important Things to Know About the Effect Hook in React
https://leanpub.com/code-react-sweetly
Effect Hooks are best for connecting components with external systems
https://leanpub.com/code-react-sweetly
Remove unnecessary reactive objects and functions from the dependency array
https://leanpub.com/code-react-sweetly
Why does the dependency array view functions and objects declared in a component’s body as changed items on every render?
https://leanpub.com/code-react-sweetly
Static objects and functions are best declared outside your component
https://leanpub.com/code-react-sweetly
Dynamic objects and functions are best declared inside your Effect Hook
https://leanpub.com/code-react-sweetly
Extract the primitive values of the objects your component received as its props
https://leanpub.com/code-react-sweetly
Effects run twice in development
https://leanpub.com/code-react-sweetly
Up next
Forms in React
In this chapter
Effect Hooks
Types of Effects in React
How to Know the Effects That Require Cleanup
How to Know the Effects That Do Not Require Any Cleanup
How to Clean Up a Component’s Effects
How to Specify When React Effects Should Run
Important Things to Know About the Effect Hook in React