TIL - React Hooks
April 07, 2020
What follows is notes from a class. Incomplete thoughts & code that probably will only make sense to me. Given enough time, even that may be a stretch! Reference at your own risk 😂
Slides
Intro to React Hooks
Hooks replace the old Class syntax!!
useEffect
The useEffect
hook is a side effect, separate to the normal process you have going on in your functions. This can replace the lifecycle methods componentDidMount
& componentDidUpdate
& componentWillUnmount
. componentWillUnmount
only comes into play if your useEffect
function returns a function: unmount
useEffect( |
More Hooks
Here are the docs for all the hooks.
My CodePen Pens
- useState Demo
- Basic useEffect Demo
- useEffect Demo With AJAX & comparing componentDidMount
- useContext Demo
- Example of a custom hook because you can make your own hooks to do things you need to do