

Hasty Treat - Why should I use React Hooks?
source link: https://syntax.fm/show/307/hasty-treat-why-should-i-use-react-hooks
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Dec 7th, 2020
Hasty Treat - Why should I use React Hooks?
👇 Download Show✏️ Edit Show NotesIn this Hasty Treat, Scott and Wes talk about React Hooks and why you might want to use them instead of class components.
Sentry - Sponsor
If you want to know what's happening with your errors, track them with Sentry. Sentry is open-source error tracking that helps developers monitor and fix crashes in real time. Cut your time on error resolution from five hours to five minutes. It works with any language and integrates with dozens of other services. Syntax listeners can get two months for free by visiting Sentry.io and using the coupon code "tastytreat".
Show Notes
03:54 - Decouple the UI from the logic
- This wasn't impossible with class-based components, but we started using HOC to do this.
- With hooks, it makes you decouple what it does and how it looks.
- Makes things like GraphQL code gen possible
- Multiple pieces of state or functionality
- Share commonly used functionality among projects and components
10:31 - Reduction in code
- Lifecycle methods were often redundant. useEffect offers a way to prevent the duplication that can happen with component did update and did mount. This gives you a way to say, "Hey, run this code when these things change."
13:30 - useEffect's dependencies
- These give you access to targeted control over side effects rather than just something changed.
14:15 - Easier to grok
- What happens? When? Where? It's mostly in the hook.
16:09 - Simplicity in usage
- Thing, updateThing is more targeted than set state
- Ref makes way more sense with useRef
- String refs weren't great, the function ref thing was obnoxious
21:07 - Gripes about Hooks
- Naming is kind of odd
- Vue did a better job with the names
Links
Tweet us your tasty treats!
Recommend
-
4
✏️ Edit Show NotesIn this Hasty Treat, Scott and Wes talk about React Suspense — what it is, how it works, support and more! Sentry - Spons...
-
5
Feb 3rd, 2020Hasty Treat - Non-Glamorous Skills You Should Have👇 Download Show✏️ Edit...
-
6
Mar 25th, 2019Hasty Treat - Why Use a Frontend Framework at All?👇 Download Show
-
8
Jun 22nd, 2020Hasty Treat - Some Neat CSS Functions That You Should Know About👇 Download Show
-
7
Aug 23rd, 2021Hasty Treat - Why Do People Hate CSS?👇 Download Show✏️ Edit Show Notes
-
10
Nov 26th, 2018Hasty Treat - Should you install a dependency or roll your own?👇 Download Show
-
9
May 25th, 2020Hasty Treat - Should You Support IE11?👇 Download Show✏️ Edit Show Notes
-
7
May 4th, 2020Hasty Treat - Things You Should Know About Javascript Events👇 Download Show
-
4
Oct 21st, 2019Hasty Treat - React Server Side Rendering👇 Download Show✏️ Edit Show Notes
-
9
Aug 19th, 2019Hasty Treat - How To Publish A React Component To NPM👇 Download Show
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK