nanlabs / nancy.js

This repository contains different React components, hooks, apps and libraries that are used in different projects here at NaN Labs.
https://nanlabs.github.io/nancy.js
MIT License
23 stars 10 forks source link

feat: Add usePrevious as custom hook #97

Closed Dhoni77 closed 1 year ago

Dhoni77 commented 1 year ago

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

coderabbitai[bot] commented 1 year ago

Walkthrough

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.

Changes

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!


Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - Mention `@coderabbitai` in any *review comment* for bot assistance. - Note: Review comments are made on code diffs or files, not on the PR overview. ### Pause Incremental Reviews - Insert `@coderabbitai: ignore` in the PR description to halt the bot's ongoing reviews. Remove the line to resume. - Additionally, enter `@coderabbitai pause` to halt the bot's ongoing reviews as any issue or review comment. To resume reviews, enter `@coderabbitai resume` as any issue or review comment.