Which hook allows you to access the previous state or props without triggering a re-render?

  • useEffect
  • useMemo
  • usePrevious
  • useState
The usePrevious custom hook allows you to access the previous state or props without triggering a re-render. It's not a built-in hook in React but is often implemented as a custom hook. The useEffect hook can be used to achieve similar functionality, but it can indirectly trigger re-renders, making usePrevious a more direct choice for this specific use case.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *