zundo
zundo copied to clipboard
Does undo/redo merge past state into current state?
Sometimes I have a zustand state where I add top-level keys dynamically. For example, it might start off like:
useSomething = create(()=>({}))
Then I might later do:
useSomething.setState({[some_id]: some_value})
If undo/redo is merging past states into the current state, then the "some_id" won't be removed.
I'm guessing it is merging, based on this line: https://github.com/charkour/zundo/blob/65a1c99d933d3ee6687b7d3e88efc36e4dee508f/src/temporal.ts#L25
It's not a big deal, as I can just add a permanent top-level key and put the dynamic keys inside of that. Adding an option to overwrite state could be nice though, unless there's a way to do that already.