Closed ma1ko closed 2 years ago
This looks correct, and I was able to run it without any issue. Sometimes this error pops up if your app has already crashed before you press a button. Is there another error message in the console besides this one?
The only part I didn't include in my test was the wasm logger, maybe that's panicking for some reason?
Thanks for looking into this!
If removed the wasm-logger and it didn't change anything, so it's not the cause.
There's actually two errors coming up in the developer console: the first is the one I posted already, the second has the exact same stacktrace but error message Uncaught RuntimeError: unreachable
, not sure what the difference is of those two. Both errors appear only when pressing the button.
The pasted code should actually show a counter when clicking the button, does this work for you?
I tried understanding the issue from the stacktrace:
$yewdux::subscriber::<impl yewdux::mrc::Mrc<yewdux::subscriber::Subscribers<S>>>::notify
immutably borrows the Mrcnotify
causes a re-render of Model
, since it is subscribedModel
creates a new Listener
(since Points
was increased) that will subscribe to the same store$yewdux::subscriber::<impl yewdux::mrc::Mrc<yewdux::subscriber::Subscribers<S>>>::subscribe
calls borrow_mut()
on the same store while still borrowed by the previous notify() and causes a panic.Does that make sense?
Looks like this is a bug with 0.8, can you confirm it is not present on the master branch?
Seems to be a problem with use_store
, because of how Yew 0.19 handles hooks. Will start working on a patch
Okay 0.8.2
has been publish with the fix!
Thanks a lot! I just tried the fix and everything seems to be working!
I managed to narrow this down to a minimal example:
This panics with a
BorrowMutError
when clicking the button. Stacktrace:As far as I understand it, if you increase the amount of state listeners while using the state, it panics. Is there any way to fix this?