usePrevious

React state hook that returns the previous state.

hooks
Description of the SVG image Loading...

As described here (legacy): https://legacy.reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state

Variants

usePreviousDistinct

Just like usePrevious but it will only update once the value actually changes. This is important when other hooks are involved and you aren't just interested in the previous props version, but want to know the previous distinct value

Description of the SVG image Loading...

with useHooks

Description of the SVG image Loading...

The usePrevious hook is a useful tool for tracking the previous value of a variable in a functional component. This can be particularly handy in scenarios where it is necessary to compare the current value with the previous one, such as triggering actions or rendering based on changes.

Installation

Run the following command:

npx ever-ui-clx@0.2.1 add demo-use-previous
# └──> Hook coming soon.

Usage