cerebral/overmind

[BUG] State changes are not reflected on the UI if using TypeScript

p32929 opened this issue ยท 7 comments

Hello, thanks for creating this amazing state management library. I have been using it in JavaScript for more than a year now & I am enjoying it. But today, I wanted to give TypeScript a try and use Overmind in it.

The state changes work but if I change some code and go back to browser, the states changes doesn't reflect on the UI any more.
Like this:

Overmind

How to reproduce:

  1. Run this project: https://github.com/p32929/react-typescript-overmind-counter-example
  2. Click on the ++ button ( It will work now )
  3. Change something in the code ( may be the texts in the p/paragraph tag )
  4. Go back to browser and click on the ++ button again ( it doesn't change the UI anymore )
  5. reload the tab
  6. Click on the ++ button ( the state changes should reflect the UI again )

Thanks again. Have a great day...

Thanks for an amazingly described issue! ๐Ÿ˜„ I will check this before next release!

It seems to be a hot reload issue

Actually, I use this library in all of my/our projects. Since, I'm not paying for it, the least I can do is to help it get better.
You're welcome :)

Okay, so I reworked how overmind-react works in terms of doing the tracking and using "native" react hooks. So now react-refresh works. You can try by installing overmind@next and overmind-react@next. Note that this is a breaking release with quite a few changes related to typing: https://gist.github.com/christianalfoni/842df6eb5a7d115b52e9462849d5ed85 . This needs a bit more testing, but it is way cleaner, so having high hopes ๐Ÿ˜„

@christianalfoni @p32929 I just ran into the same issue but with Preact + https://www.npmjs.com/package/@prefresh/next โ€ฆ is this not supported or is this issue not yet solved on the overmind side?

I have a working compromise for now: I use react for development and preact for production build. Would be amazing if Overmind supported Preact / prefresh, since this would prevent issues that might arise due to the differences between react/preact ๐ŸŽ‰

Released! ๐ŸŽ‰

Hi @christianalfoni, seems like there's a similar issue with hooks on vue 3.