We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using mobx-persist with SSR, I have these messages (printed like 10 times) both in dev or in production mode:
ReferenceError: window is not defined at /home/www/my-project/node_modules/mobx-persist/lib/storage.js:18:45
How can I suppress them? Should window and localstorage be polyfilled?
The text was updated successfully, but these errors were encountered:
import { create } from 'mobx-persist' if (isBrowser /* or !isServer */) { const hydrate = create(...) hydrate('yourStoreKey', yourStore, yourStateFromServer) }
Sorry, something went wrong.
Thanks, it's working! Maybe the doc can be completed with your code snippet?
Here's what I used in my project:
import { action, observable } from 'mobx' import { persist, create } from 'mobx-persist' class User { @observable hydrated = false @persist('object') @observable _content = null @action hydrateComplete() { this.hydrated = true } ... } let userStore = new User() export default userStore if (process.browser) { const hydrate = create({ jsonify: true }) hydrate('user', userStore).then(() => userStore.hydrateComplete()) }
No branches or pull requests
When using mobx-persist with SSR, I have these messages (printed like 10 times) both in dev or in production mode:
How can I suppress them? Should window and localstorage be polyfilled?
The text was updated successfully, but these errors were encountered: