Closed Dhoni77 closed 1 year ago
This change introduces a new custom React hook, usePrevious
, which keeps track of the previous state value. An example usage of this hook is demonstrated in an Example
component that maintains a count state and updates it based on user interaction.
File | Summary |
---|---|
.../hooks/usePrevious.stories.tsx |
Added a new Example component demonstrating the usage of the usePrevious hook. |
packages/react-hooks/index.ts |
Updated import statements to use double quotes instead of single quotes. |
packages/react-hooks/use-previous/index.ts |
Added a new export statement for the usePrevious module. |
packages/react-hooks/use-previous/usePrevious.ts |
Introduced a new file exporting the usePrevious hook, which returns the previous state value. |
🐇💻
In the land of code, changes are afoot,
A new hook is born, isn't that good?
It remembers the past, as all good hooks should,
Making our components understood.
So let's celebrate this code, so neat and fine,
With carrots and bytes, in a line!
What's this PR do?
Related issue: #92
Implemented the usePrevious hook to keep track of the previous value.
@ulises-jeremias @rpmolina
Summary by CodeRabbit
usePrevious
in the@nanlabs/react-hooks
library. This hook allows developers to easily access the previous state in their functional components.Example
component in the playground app to demonstrate the usage of theusePrevious
hook. The component includes a counter with increment and decrement functionality, displaying both the current and previous count values.