-
Notifications
You must be signed in to change notification settings - Fork 866
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
Importing storage on the server shows error #802
Comments
Yes, it looks like the module has side effects - storage/index.js exports the result of calling
If you just need to silence the error in unit tests, just mock the module to do nothing using eg. Jest's manual mock https://facebook.github.io/jest/docs/en/manual-mocks.html |
@ZhangYiJiang i still can't get it working using mocks :( |
I am also getting this error on a server when working with Next.js + Redux persist:
Using:
My workaround:
|
@tomaswitek Run your app in @tje3d What I did was to write a wrapper around
I'm using Jest, but other mocking libraries should have similar functionality
|
Thx @ZhangYiJiang |
@Floriferous I'm getting the same console error in my terminal when I started my App configured with SSR
|
Hi @rubenesda, I'm not using this package anymore, I don't really remember this issue. Try to avoid importing LocalStorage on your server-side code, and have a client-only persistor. |
I'm using
redux-persist
in an SSR setup, and I'm getting an annoying issue on the server when I try to importstorage
:While I know that it doesn't make sense to use localStorage on the server, I also do not actually use it in my server setup, but this is shared code between the client and server.
Could there be a way to share code without having to resort to conditional imports (my current workaround) ?:
Or maybe the error message should be dropped altogether, given that it's not really helpful anyways (why did it fail..?)? It took me quite some time between all the different components and functions of this package to figure out that merely importing localStorage was causing the error.
EDIT: typo
The text was updated successfully, but these errors were encountered: