Mobx-state-tree: HMR not support ?

Created on 7 Sep 2017  Â·  6Comments  Â·  Source: mobxjs/mobx-state-tree

i am surprisely found that hot-reload is not supported in mobx/MST world . everytime ,even a little changes on the store ,i need to reload the entire page . thats really a big pain in the ass ..

is there any solutions so far ?

Most helpful comment

For future readers, here is an example to set up HMR for both React components and MST models (and also store the state in local storage, stripping that would simplify the example a bit):

https://github.com/mobxjs/mobx-state-tree/blob/a0916791768637665a56bc2720ec0a081d4d148f/packages/mst-example-todomvc/src/index.js#L30-L70

All 6 comments

Try the very latest hot loader beta. Does that help?

On Thu, Sep 7, 2017, 6:11 AM xieyiming notifications@github.com wrote:

i am surprisely found that hot-reload is not supported in mobx/MST world .
everytime ,even a little changes on the store ,i need to reload the entire
page . thats really a big pain in the ass ..

is there any solutions so far ?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mobxjs/mobx-state-tree/issues/372, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAIrcqJP4clI-lPpFfuc4oWkmRkbCBrgks5sf89dgaJpZM4PPqIY
.

no luck ..

i use the next.js and the hot-loader is the latest beta version

It won't work unless you make it so
you need use
https://webpack.js.org/api/hot-module-replacement/

...which is basically as simple as shown here: https://twitter.com/mhaagens/status/911587350429491200

For future readers, here is an example to set up HMR for both React components and MST models (and also store the state in local storage, stripping that would simplify the example a bit):

https://github.com/mobxjs/mobx-state-tree/blob/a0916791768637665a56bc2720ec0a081d4d148f/packages/mst-example-todomvc/src/index.js#L30-L70

Is it possible to achieve this without passing store as a prop? (i.e exporting store variable and using directly in react components)

Was this page helpful?
0 / 5 - 0 ratings