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

Does not work 1 #53

Open
dsame opened this issue May 27, 2018 · 4 comments
Open

Does not work 1 #53

dsame opened this issue May 27, 2018 · 4 comments

Comments

@dsame
Copy link

dsame commented May 27, 2018

`import { observable, action } from 'mobx';
import { create, persist } from 'mobx-persist';

const DEFAULT_ZOOM = 5;
class Map {
@persist
@observable
zoom = DEFAULT_ZOOM;
}

class UI {
@observable hydrated = false;
@observable map = new Map();
}

const ui = new UI();

const hydrate = create({});

export default ui;
hydrate('map2ui', ui)
`

causes
mobx.module.js?daf9:3516 [mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[Reaction@1] Error: [serializr] Failed to find default schema for undefined at invariant (serializr.js?967d:44) at Object.serialize (serializr.js?967d:363) at mobx_1.reaction.delay (index.js?b78b:47) at eval (mobx.module.js?daf9:600) at trackDerivedFunction (mobx.module.js?daf9:3287) at Reaction.track (mobx.module.js?daf9:3491) at reactionRunner (mobx.module.js?daf9:599) at Reaction.eval [as onInvalidate] (mobx.module.js?daf9:587) at Reaction.runReaction (mobx.module.js?daf9:3463) at runReactionsHelper (mobx.module.js?daf9:3589)

@dsame
Copy link
Author

dsame commented May 27, 2018

The problems seems to appear if there's no at least one persisted field in the object. But i really do not want to persist any of child stories. I want to persist storie's properties (some of them)

@designbyadrian
Copy link

I spent hours trying to figure this out. @dsame 's reply helped. I'm now adding one as soon as my store is constructed, but this is only sometimes a viable solution.

@shrugs
Copy link

shrugs commented May 13, 2019

I'd expect that you can also only hydrate that one child store hydrate("map", ui.map) without a problem.

@marcelxsilva
Copy link

This error occurs when, for example, a store called user does not have persist inside it, but in the store's index it hashydrate('user', stores.user).

Just remove hydrate('user', stores.user) and the problem will be solved.

it worked for me.

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

4 participants