In this thread, I’ll break down and provide illustrations of the six main hooks in React.js ⚛️
You will leave with a clear understanding of;
→ What each hook does? ⛓
→ Why to use each hook? 💡
You will leave with a clear understanding of;
→ What each hook does? ⛓
→ Why to use each hook? 💡
React hooks were the death of class components 💀
Hooks were released in v16.8 and gave us access to all the features in class components but without so much boilerplate code🤮
It was a fresh breath of life for React.js, that changed web development to this day 🚀
Hooks were released in v16.8 and gave us access to all the features in class components but without so much boilerplate code🤮
It was a fresh breath of life for React.js, that changed web development to this day 🚀
1a) Why use useState() ?
→ To make UI interactive, you need to be able to trigger changes to your underlying data model or component. React achieves this with state 💡
→ The useState hook gives you a clean, concise method to work with state.
→ To make UI interactive, you need to be able to trigger changes to your underlying data model or component. React achieves this with state 💡
→ The useState hook gives you a clean, concise method to work with state.
2a) useEffect() runs after every render.
React can skip an effect if certain values haven’t changed between re-renders. To do so, pass an [] as an optional 2nd argument 🙌
There is also an optional cleanup function to unsubscribe any subscriptions & not introduce memory leaks.
React can skip an effect if certain values haven’t changed between re-renders. To do so, pass an [] as an optional 2nd argument 🙌
There is also an optional cleanup function to unsubscribe any subscriptions & not introduce memory leaks.
That's a wrap!
If you enjoyed this thread, don’t forget to like, comment, and retweet the first tweet!
I create threads, and hand-drawn illustrations to level up your software development game 🚀 🧵 🎨
Follow @ChrisStaud
for more free tips and free resources.
If you enjoyed this thread, don’t forget to like, comment, and retweet the first tweet!
I create threads, and hand-drawn illustrations to level up your software development game 🚀 🧵 🎨
Follow @ChrisStaud
for more free tips and free resources.
Loading suggestions...