Skip to content

Don't remember which hook to use? Here's a quick reference sheet to go through all the options and understand the differences between each one.

License

Notifications You must be signed in to change notification settings

VictorienDotNet/React-Hook-Cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

React Hook Cheatsheet

Don't remember which hook to use? Here's a quick reference sheet to go through all the options and understand the differences between each one. Below is a list of official hooks (⚛️) as well as custom hooks (✴️).

Hooks

Manage Component State

  • ⚛️ useState
    Read and update local values from a component
  • ✴️ useKeyedState
    Read and update values from an individual item within a component

Share Data Across Components

  • ⚛️ useContext
    Read data shared across descendant components
  • ✴️ useStore
    Share data between components in different parts of the app
  • ⚛️ useRef
    Store data without triggering a component re-render

Work With the DOM and External JS

  • ⚛️ useEffect
    Run side effects after the component has rendered
  • ⚛️ useLayoutEffect
    Run side effects before the browser paints the screen
  • ⚛️ useRef
    Access DOM elements directly

Optimize Rendering

  • ⚛️ useMemo
    Recalculate a value only when dependencies change
  • ⚛️ useCallback
    Redefine a function only when dependencies change

About

Don't remember which hook to use? Here's a quick reference sheet to go through all the options and understand the differences between each one.

Topics

Resources

License

Stars

Watchers

Forks