Skip to content

Does undo/redo merge past state into current state? #196

Description

@KevinMusgrave

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:

userSet(nextState);

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions