localStorage is not defined.
See original GitHub issueI guess this is due to lack of localStorage support in jsdom.
Starting` crawling http://localhost:59817/ Failed to retrieve initialize state from localStorage: ReferenceError: localStorage is not defined at http://localhost:59817/static/js/main.923fa5f4.js:24:24448 at http://localhost:59817/static/js/main.923fa5f4.js:24:26074 at o (http://localhost:59817/static/js/main.923fa5f4.js:13:23313) at Object.<anonymous> (http://localhost:59817/static/js/main.923fa5f4.js:14:24180) at t (http://localhost:59817/static/js/main.923fa5f4.js:1:107) at Object.<anonymous> (http://localhost:59817/static/js/main.923fa5f4.js:1:505) at t (http://localhost:59817/static/js/main.923fa5f4.js:1:107) at http://localhost:59817/static/js/main.923fa5f4.js:1:195 at http://localhost:59817/static/js/main.923fa5f4.js:1:200 at ContextifyScript.Script.runInContext (vm.js:32:29) Unable to persist state to localStorage: ReferenceError: localStorage is not defined at Array.<anonymous> (http://localhost:59817/static/js/main.923fa5f4.js:24:24646) at d (http://localhost:59817/static/js/main.923fa5f4.js:13:22744) at http://localhost:59817/static/js/main.923fa5f4.js:24:306 at Object.dispatch (http://localhost:59817/static/js/main.923fa5f4.js:24:25796) at t.r.handleLocationChange (http://localhost:59817/static/js/main.923fa5f4.js:23:31542) at t.componentWillMount (http://localhost:59817/static/js/main.923fa5f4.js:23:31796) at c.performInitialMount (http://localhost:59817/static/js/main.923fa5f4.js:21:17205) at c.mountComponent (http://localhost:59817/static/js/main.923fa5f4.js:21:16373) at Object.mountComponent (http://localhost:59817/static/js/main.923fa5f4.js:3:7565) at c.performInitialMount (http://localhost:59817/static/js/main.923fa5f4.js:21:17487) ✏️ Saving / as /index.html
Issue Analytics
- State:
- Created 6 years ago
- Reactions:14
- Comments:16
Top GitHub Comments
I solved it by adding local-storage polyfill for development dependency
npm i -D localstorage-polyfill
ORyarn add -D localstorage-polyfill
In your App’s index.js file add following:
import 'localstorage-polyfill'
This solved error for me.
You should not use
localStorage
instance in the component’srender
or any method that is evaluated in the server. Move localStorage calls in the componentWillMount method for example. I’ve solved my problem this way.