use-frozen-state
React hook that makes sure your state is immutable. Call useFrozenState
or useDeepFrozenState
instead of useState.
Features:
- Tiny and dependancy free
- Built with Typescript
Install
npm install --save use-frozen-state
Usage
Pick from useFrozenState
and useDeepFrozenState
.
useFrozenState
will shallow freeze the state. (example)useDeepFrozenState
will traverse through the state object and freeze it all. (example)- Need selective deep freezing? Supply
useDeepFrozenState
a second parameter:deepFreezeFn
. (example)
useFrozenState
example
;; ;
useDeepFrozenState
example
;; ; ;
deepFreezeFn
example
;; ; ;
License
MIT © NoamRa
This hook is created using create-react-hook.