Chapter 7 : Enhancing Components with Hooks

Samples

useEffect hook

The Dependency Array

When to useLayoutEffect

  • Basic useLayoutEffect - (run it)

  • Custom: useWindowSize - (run it)

  • Custom: useMousePosition - (run it)

useReducer

  • Checkbox with useState - (run it)

  • Checkbox with toggle - (run it)

  • Checkbox with useReducer - (run it)

  • Increment number with useReducer - (run it)

useReducer to handle Complex State

  • useState with objects - (run it)

  • useReducer with objects - (run it)

  • legacy setState with useReducer - (run it)

Last updated