Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Awesome React Hooks

Awesome React Hooks

Avatar for thereactboy

thereactboy

October 12, 2019
Tweet

More Decks by thereactboy

Other Decks in Programming

Transcript

  1. • Software Developer and Mentor at Coding Blocks. • Co-Founder

    @ Voz, A content community platform thevoz.in • Final Year Student, B.E. Computer Engineering, Thapar University. Tathagat Thapliyal
  2. “To think creatively, we must be able to look afresh

    at what we normally take for granted” - George Keller A react feature that lets you use state and Lifecycles without writing a class based react component.
  3. Most forgetful and toughest error to figure out for beginners

    Code smelling all over the place Might need to duplicate this in some other component Class based component
  4. HOC

  5. So What? ‍♂ HOCs Render Props Hooks Reuse Stateful Logic

    ✅ ✅ ❓ Explicit Props ❌ ✅ ❓ Composability ✅ ❌ ❓ No “Wrapper Hell” ❌ ❌ ❓
  6. SPOILER ALERT!! HOCs Render Props Hooks Reuse Stateful Logic ✅

    ✅ ✅ Explicit Props ❌ ✅ ✅ Composability ✅ ❌ ✅ No “Wrapper Hell” ❌ ❌ ✅
  7. More Hooks API’s Basic Hooks • useState() • useContext() •

    useEffect() Advanced Hooks • useReducer() • useCallback() • useEffect() • useMemo() • useRef()
  8. • Easier to work with . • Easier to test.

    • More readability. • Few lines of code. • No new component formation on DOM. Conclusion?
  9. Half screen photo slide if text is necessary References •

    https://www.polidea.com/blog/react-hooks-vs-wr apper-hell-writing-state-in-a-function-with-ease/ • https://blog.logrocket.com/frustrations-with-react- hooks/ • https://reactjs.org/docs/hooks-intro.html • https://medium.com/@jackyef/react-hooks-why- we-should-embrace-it-86e408663ad6