@tsx-use/state-with-history@0.1.0
Takes an `initialState: T` and produces an object that has properties `initial`, `previous`, & `current`, as well as methods `set` (current), `revert` (to previous), & `reset` (to initial).
This package works with Browsers
JSR Score
64%
Published
a day ago (0.1.0)
@tsx-use/state-with-history
Takes an initialState: T
and produces an object that has properties initial
, previous
, & current
, as well as methods set
(current), revert
(to previous), & reset
(to initial).
Usage
import { useStateWithHistory } from '@tsx-use/state-with-history' interface ComponentProps { total: number } function Component({ total: 0 }: ComponentProps) { const { initial, previous, current, set: setTotal, revert: revertTotal, reset: resetTotal } = useStateWithHistory(total); // TODO: think of a good use case that's not too complicated... }