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

Error restoring data for key:todoList [ReferenceError: localStorage is not defined] #41

Closed
jinaymehta25 opened this issue Nov 19, 2015 · 6 comments

Comments

@jinaymehta25
Copy link

I am seeing this error in console and most probably that's happening on the node server side (isomorphic app). Is there a way to handle this?

@rt2zz
Copy link
Owner

rt2zz commented Nov 19, 2015

yes this is a relatively easy fix

question though: how do you expect redux-persist to work on the server? are you expecting a noop?

@zalmoxisus
Copy link
Contributor

Unless you do not store states on the server side, you don't need Redux Persist there. A solution could be to move store persisting in a separate module and import it only on the client side or to have 2 different implementations depending on the side. Like here.

@jinaymehta25
Copy link
Author

@rt2zz : Yes something like noop. @zalmoxisus: I saw your solution, exactly how do you decide where is the app running?

@zalmoxisus
Copy link
Contributor

In that example, I just add the environment flag to the second parameter of configureStore, but in case of an universal ("isomorphic") app it's even easier, you may just use, for example, process.env.isServer.

Using redux-persist as a noop wouldn't be a good solution, as it tries to persist new state on every action.

@rt2zz
Copy link
Owner

rt2zz commented Nov 29, 2015

just released 1.4.5

no localStorage now console.errors with a useful message. In production it is a noop.

@zalmoxisus I do not think process.env.isServer is defined in most node environments. AFAIK the tyipical albeit indirect way to check if in node is https://gist.github.com/rt2zz/ac9eb396793f95ff3c3b

@rt2zz rt2zz closed this as completed Nov 29, 2015
@jinaymehta25
Copy link
Author

thanks @rt2zz and @zalmoxisus !!

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