Skip to content
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

usage with react can cause race conditions with computed properties derived from persisted value #43

Open
r3wt opened this issue Jan 25, 2018 · 2 comments

Comments

@r3wt
Copy link

r3wt commented Jan 25, 2018

here is how i had to solve it, by not mounting the app until store was hydrate.

import App from './App';
import store from './Store';//herre is where persist is imported and applied as necessary.
import { create } from 'mobx-persist';
const storeName='foobar';

create()(storeName,store).then(()=>{
    ReactDOM.render(
        <App store={store} />
        , document.getElementById('root'));    
    setTimeout(()=>registerServiceWorker)
});

this is dangerous because computed properties don't cause rerenders in mobx. if this is a bug in mobx instead, feel free to notify them.

@r3wt r3wt changed the title usage with react can cause race conditions usage with react can cause race conditions with computed properties derived from persisted value Jan 25, 2018
@designbyadrian
Copy link

designbyadrian commented Mar 19, 2018

I agree. I can't figure out when you should call hydrate?

I've got a few components that call the stores from componentWillMount, but there is no example of how to mix that with hydrate.

@MrGurns
Copy link

MrGurns commented Apr 9, 2018

I believe you want to rehydrate the data everytime it is updated, but i'm not entirely sure yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants