Syntax - Tasty Web Development Treats

Hasty Treat - Why should I use React Hooks?


Listen Later

In 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
  • https://github.com/pmndrs/jotai
  • https://github.com/rehooks
  • https://twitter.com/youyuxi/status/1327328144525848577/photo/1
  • Tweet us your tasty treats!
    • Scott’s Instagram
  • LevelUpTutorials Instagram
  • Wes’ Instagram
  • Wes’ Twitter
  • Wes’ Facebook
  • Scott’s Twitter
  • Make sure to include @SyntaxFM in your tweets
  • ...more
    View all episodesView all episodes
    Download on the App Store

    Syntax - Tasty Web Development TreatsBy Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

    • 4.9
    • 4.9
    • 4.9
    • 4.9
    • 4.9

    4.9

    977 ratings


    More shows like Syntax - Tasty Web Development Treats

    View all
    Software Engineering Radio by se-radio@computer.org

    Software Engineering Radio

    270 Listeners

    Hanselminutes with Scott Hanselman by Scott Hanselman

    Hanselminutes with Scott Hanselman

    383 Listeners

    The Changelog: Software Development, Open Source by Changelog Media

    The Changelog: Software Development, Open Source

    290 Listeners

    Software Engineering Daily by Software Engineering Daily

    Software Engineering Daily

    623 Listeners

    Talk Python To Me by Michael Kennedy

    Talk Python To Me

    585 Listeners

    Soft Skills Engineering by Jamison Dance and Dave Smith

    Soft Skills Engineering

    289 Listeners

    Thoughtworks Technology Podcast by Thoughtworks

    Thoughtworks Technology Podcast

    43 Listeners

    Python Bytes by Michael Kennedy and Brian Okken

    Python Bytes

    215 Listeners

    The freeCodeCamp Podcast by freeCodeCamp.org

    The freeCodeCamp Podcast

    487 Listeners

    CoRecursive: Coding Stories by Adam Gordon Bell - Software Developer

    CoRecursive: Coding Stories

    190 Listeners

    Practical AI by Practical AI LLC

    Practical AI

    207 Listeners

    The Stack Overflow Podcast by The Stack Overflow Podcast

    The Stack Overflow Podcast

    63 Listeners

    The Real Python Podcast by Real Python

    The Real Python Podcast

    141 Listeners

    PodRocket by LogRocket

    PodRocket

    60 Listeners

    Oxide and Friends by Oxide Computer Company

    Oxide and Friends

    62 Listeners