0.3.5 • Published 1 year ago
use-hashed-state v0.3.5
use-hashed-state
use-hashed-state
is a hook library from plasmo to safely store data in localstorage with an unique key of any
type, even a component.
The library is a typescript fork of use-persisted-state-hook but instead of md5
, is uses node-object-hash
, and it hashes both the key and the values.
Example
The Check
component below is capable of having a state simply based on the content of its children - it is fully independent.
import { useHashedState } from "use-hashed-state"
const Check = ({ children = "" as ReactNode }) => {
const [checked, setChecked] = useHashedState<boolean>(
children,
false,
"plasmo-soc2"
)
return (
<Checkbox checked={checked} onChange={() => setChecked((c) => !c)}>
{children}
</Checkbox>
)
}
// Consume in another component:
const Container = () => (
<>
<Check>
<WaveIcon /> Waved
</Check>
<Check>
<ClockTick />
</Check>
</>
)
Usage in the wild
Why?
To boldly go where no one has gone before
Acknowledgment
License
0.3.5
1 year ago
0.3.2
1 year ago
0.4.0
1 year ago
0.3.4
1 year ago
0.3.0
1 year ago
0.3.1
1 year ago
0.2.1
2 years ago
0.2.0
2 years ago
0.2.2
2 years ago
0.1.6
2 years ago
0.2.4
2 years ago
0.1.5
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago