
Hasty Treat - Why should I use React Hooks?
HAYA
Description
<p class="has-line-data" data-line-start="7" data-line-end="8">In this Hasty Treat, Scott and Wes talk about React Hooks and why you might want to use them instead of class components.</p> <h2 class="code-line" data-line-start="9" data-line-end="10"><a id= "Sentry__Sponsor_9" name="Sentry__Sponsor_9"></a>Sentry - Sponsor</h2> <p class="has-line-data" data-line-start="10" data-line-end="11">If you want to know what’s happening with your errors, track them with <a href="https://sentry.io/">Sentry</a>. 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 <a href= "https://sentry.io/">Sentry.io</a> and using the coupon code “tastytreat”.</p> <h2 class="code-line" data-line-start="12" data-line-end="13"> <a id="Show_Notes_12" name="Show_Notes_12"></a>Show Notes</h2> <p class="has-line-data" data-line-start="14" data-line-end="15"> 03:54 - Decouple the UI from the logic</p> <ul> <li class="has-line-data" data-line-start="15" data-line-end="16"> This wasn’t impossible with class-based components, but we started using HOC to do this.</li> <li class="has-line-data" data-line-start="16" data-line-end="17"> With hooks, it makes you decouple what it does and how it looks.</li> <li class="has-line-data" data-line-start="17" data-line-end="18"> Makes things like GraphQL code gen possible</li> <li class="has-line-data" data-line-start="18" data-line-end="19"> Multiple pieces of state or functionality</li> <li class="has-line-data" data-line-start="19" data-line-end="21"> Share commonly used functionality among projects and components</li> </ul> <p class="has-line-data" data-line-start="21" data-line-end="22"> 10:31 - Reduction in code</p> <ul> <li class="has-line-data" data-line-start="22" data-line-end="24"> Lifecycle methods were often redundant. useEffect offers a way to prevent the dupli