-
Notifications
You must be signed in to change notification settings - Fork 865
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
localForage and getStoredState from Redux Persist #264
Comments
i wrote a fake local storage implementation that can be passed in as |
@modosc awesome thanks for sharing!! |
you can also use something like https://www.npmjs.com/package/redux-persist-cookie-storage to store cookies which do not cause errors or warning. In the future we will probably ship a recommended |
Note that cookies also can be disabled. So, I guess we should just not store anything if the user opted not to |
@zalmoxisus good idea. I wish there was a clear way to distinguish "storage not allowed" from "storage error". Perhaps we should just be conservative in our fallback and warn in dev. |
we're using both |
update: i published https://github.com/modosc/redux-persist-memory-storage as a general purpose solution - we've had to use this pattern for clients with cookies or localstorage disabled. |
Just wondering - looking one step back - wouldn't localForage by itself fail when localStorage is not available and simply go to the next driver? Wouldn't just defining memoryStorage as the fallback driver solve those issues (and still be within localForage functionality)? PS: we could also simply extend isLocalStorageValid to actually try to call .setItem() and thus invalidate localStorage in case of Safari (or any other) errors. |
Using getStoredState while in incognito mode or with cookies disabled in Safari causes the store to never be made available. localForage rejects it's promise with the SecurityError thrown by Safari.
Since understanding how redux-persist and localForage interplay in this scenario and how to resolve that is too large a task for me I simply revert to not using localForage if I can get an error by trying to access localStorage like so:
This stops my app from breaking when it starts but the console does get littered with warnings while in this mode.
The text was updated successfully, but these errors were encountered: