zundo icon indicating copy to clipboard operation
zundo copied to clipboard

`clear` seems to be resetting my entire store state.

Open jo-sip opened this issue 1 year ago • 3 comments

Hi.

I think the latest change might have potentially broken clear from the middleware. When I call it to reset my history, it seems to wipe my entire store and I get Cannot destructure property 'X' of 'myStore(...)' as it is undefined, when I use my store. I don't think I changed any of my code except updating npm. When I comment my call of clear out (when I want to reset the store and want a brand new history), it errors.

jo-sip avatar Sep 04 '22 01:09 jo-sip

Hey @jo-sip, thanks for making an issue! I can check this out soon. What will help me debug is reproduction steps or a code sandbox. Thank you!

charkour avatar Sep 05 '22 11:09 charkour

No worries, here's a simple example that repros the bug. https://codesandbox.io/s/clear-debug-zundo-6rde7m?file=/src/App.tsx

(Add a few, undo, then clear and it'll throw)

jo-sip avatar Sep 06 '22 18:09 jo-sip

Great, thank you! I was able to reproduce the issue. Very strange.

I can look into this! For the time being, I'd roll back to the previous version.

charkour avatar Sep 06 '22 18:09 charkour

I'm not sure what's wrong with that version.

v2 beta should fix this issue. There is a small API change for accessing undo and redo but the readme explains how to use that. Sorry again for the issue and for the delay!

npm i zundo@beta

charkour avatar Sep 23 '22 03:09 charkour