Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Undo issue with array.push #397

Open
Shubhajit01 opened this issue Nov 15, 2024 · 0 comments
Open

Bug: Undo issue with array.push #397

Shubhajit01 opened this issue Nov 15, 2024 · 0 comments

Comments

@Shubhajit01
Copy link

I am currently using @legendapp/state version 3.0.0-beta.19, and facing a strange issue with arrays and undo.

Details -

  • I am storing a list of items in the observable
  • I push something to the observable array - todos$.items.push(todo). It gets added as expected and react renders the new item.
  • When I invoke undo
    • It replaces the item with a null instead of making the array as empty.
    • But, the undo works perfect when I do something like todos$.items.set(pre => [...pre, todo]) instead of a push

This happens when there is only one element in the array and undo is called.

Reproduction Link - https://codesandbox.io/p/sandbox/w7yn9l

Am I missing something here, or is there some conditions before using undo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant