Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dkershner6/use-immer-produce
React Hook nearly identical to use-immer, but it returns the draft from the update function.
https://github.com/dkershner6/use-immer-produce
hacktoberfest npm-package react react-hooks
Last synced: 29 days ago
JSON representation
React Hook nearly identical to use-immer, but it returns the draft from the update function.
- Host: GitHub
- URL: https://github.com/dkershner6/use-immer-produce
- Owner: dkershner6
- License: apache-2.0
- Created: 2020-07-24T18:26:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-14T00:17:51.000Z (7 months ago)
- Last Synced: 2024-04-14T01:13:56.904Z (7 months ago)
- Topics: hacktoberfest, npm-package, react, react-hooks
- Language: TypeScript
- Homepage:
- Size: 356 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# use-immer-produce
React Hook nearly identical to use-immer, but it returns the draft from the update function.
## Installation
```
npm i use-immer-produce immer
```## Usage
```typescript
const [testObj, updateTestObj] = useImmerProduce({
value: 14
});
```In order to immediately extract the draft, before re-render:
```typescript
const draft = updateTestObj((draft) => {
draft.value = 75;
});
```## Contributing
All contributions are welcome, please open an issue or pull request.
To use this repository:
1. `npm i -g pnpm` (if don't have pnpm installed)
2. `pnpm i`
3. `npx projen` (this will ensure everything is setup correctly, and you can run this command at any time)
4. Good to make your changes!
5. You can run `npx projen build` at any time to build the project.