React hooks: useEffect and useCallback
These are my notes on using React hooks.
useEffect
- Use to perform anything that has side-effects (API calls, modify local storage, etc)
- This does not block visual renders
useCallback
Use to create a memoized function that doesn’t have to change during renders - unless one of the dependencies have changed.
To run something that has a side-effect
- Use
useCallback
to create a memoized function - Then
useEffect
over the memoized function to mark it as as having side-effects