0

EDIT: Found out it was redux-persist who had breaking changes in a patch revision.


I'm developping a webapp in Node, React, Redux, Webpack, etc. One of the packages (redux-persist) suddenly throws an error (Uncaught TypeError: storage.getItem is not a function ( persistStore.js:99) when rehydrating the state (reading from localStorage).

Hints:

  • This problem does not occur on my collegue's environment.
  • This happened after trying to update my packages to Babel 6. But I don't see why this would be related.
  • I tried npm cache clean
  • I tried deleting and re-cloning my repo.
  • I tried brew upgrade and OSX updates (why not anyway!?)
  • It happens on Chrome, Safari which is the first time I opened it, and Firefox which I just installed for this purpose.
  • I tried git reset --hard; git clean -xfd; npm install to a state before ever using redux-persist, and it didn't throw the error.

My conclusion is that it is clearly related to my environment, since I can't find anything on this on the web, plus it's not reproducible on my coworker's environment. But I'm out of ideas.

Thanks for your help.

lcoderre
  • 1,304
  • 9
  • 16
  • 1. Are you using a browser version that supports HTML5 localStorage? 2. Is the call properly scoped (should be as localStorage is part to the window object - unless you are specifically using closures and not passing in the Window reference.) – Korgrue Feb 09 '16 at 16:08

2 Answers2

1

This was a bug in redux-persist@1.5.2 in the way we instantiate the default storage engine.

I just released 1.5.3 which resolves the bug.

zackz
  • 113
  • 6
0

One idea is that your browser might be in incognito (private) mode. There is an issue with safari about this, see this question.

Community
  • 1
  • 1
Bogdan M.
  • 1,128
  • 1
  • 9
  • 23
  • redux-persist does a try / catch on the localStorage calls for this reason. If there is an error it does a noop with a warning. Not sure if there is a more elegant way to handle this scenario... – zackz Feb 09 '16 at 20:42