-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Hot module reloading and ES6 class mobx stores #254
Comments
Something like this: https://github.com/mobxjs/mobx-reactive2015-demo/blob/master/src/stores/domain-state.js#L97 ? |
Saw that already but any suggestions as to how to deserialize and serialize with ES6 class stores? |
There is no standard solution for that in MobX, but you might use Op do 19 mei 2016 om 13:33 schreef Eric John Juta <notifications@github.com
|
Yeah surprisingly managed to get it partially working with React Hot Loader 3.0-beta.2 although my stores are resetting back to initial state |
https://gist.github.com/rej156/4524b59ea77a697fb62a39eada5b9bbe |
Small note: HMR is the transport that gets updated JavaScript into the browser. It is not the thing that detects React components or patches them. Vanilla HMR API just lets you say that module A knows what to do when a module B is updated. |
@gaearon you are right, this comment is a bit short through the corner, I still use webpack HMR for reloading the app, but not anymore to preserve the state of React components, it is doable (see the mobx docs), or even app state at all. It can all be done, but personally I'm fine nowadays with an automated full refresh of the app, instead of trying to recover state. Routing is usually enough to bring me almost at the same state again. I'm in favor of thinking instead of trying anyways when developing ;-). |
A related problem I'm having right now is that hot reloading React components that have @computed class properties breaks. Patching doesn't skip them and an error happens because they are "get" only. |
This might also be useful for others reading this issue: https://gist.github.com/rej156/4524b59ea77a697fb62a39eada5b9bbe |
Thanks to @rej156 now I updated my stack too with the hot-reloadable mobx stores: |
Thanks for sharing @foxhound87! |
Is there any problem with this code in index.tsx?
// Type definitions for webpack (module API) 1.13 I don't have any problem including hot-reload es6 class store |
Hi I was curious if you knew of any example where modifying a store would not reset the state within the running application while using React-HMR?
It's because instantiating an ES6 class store would create a new object and call its constructor reinitiating state afaik.
The text was updated successfully, but these errors were encountered: