Introduction to React Hooks

TechnoZaure Mai 2019

Christopher Kade (@christo_kade)

They let you use state and other React features without writing a class.

100% backwards-compatible. Hooks don’t contain any breaking changes.

(allow you to) build your own Hooks to share reusable stateful logic between components.

Hooks...

useState

useEffect

Custom hook(s)

useState

Bye bye setState? 🤷‍♂️

What if my state is computed based on the previous state?

useEffect

Sayonara, lifecycle hooks? 👋

How can I run clean-ups for my component?

Method is run before the component is removed from the UI

Custom Hooks

A (small) example of cleaning up a component 🧼

🎉

Recap

useContext

useReducer

useCallback

useMemo

useRef

useImperativeHandle

useDebugValue

useLayoutEffect

Merci ❤️

Introduction to React Hooks

By christopherkade

Introduction to React Hooks

  • 633