Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artcom/use-selector-once-hook
A react hook for memoizing the redux state on mount time.
https://github.com/artcom/use-selector-once-hook
Last synced: about 1 month ago
JSON representation
A react hook for memoizing the redux state on mount time.
- Host: GitHub
- URL: https://github.com/artcom/use-selector-once-hook
- Owner: artcom
- Created: 2021-07-05T13:12:34.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-06T07:28:27.000Z (over 3 years ago)
- Last Synced: 2024-12-07T19:44:56.101Z (2 months ago)
- Language: JavaScript
- Size: 552 KB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Use Selector Once Hook
A react hook for memoizing the redux state on mount time. It povides the state of the store on the first rendering and does not lead to re-render due to state updates. Equivalent to redux *useSelector* hook, *useSelectorOnce* expects a selector function as parameter.
## Installation```bash
npm i @artcom/use-selector-once-hook --save
```
## Example```javascript
import React from "react"
import { useSelectorOnce } from "@artcom/use-selector-once-hook"const MyComponent = () => {
const memoizedCounter = useSelectorOnce(state => state.counter)
}
```## Tests
See [tests](./test/useSelectorOnce.test.js).
```bash
npm i && npm run test
```