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.
Loading...
Related Quiz
- How to pass params to history.push method in React Router v4?
- How can you prevent a functional component from re-rendering when its parent re-renders, even if its props haven't changed?
- In the context of React development, how does a Service Worker contribute to the performance and reliability of a web application?
- When using React.lazy(), it's recommended to handle network failures using a component that wraps around ________.
- What is a Progressive Web App (PWA)?