Redux-persist: Uncaught ReferenceError: setImmediate is not defined ?

Created on 28 Jan 2016  路  5Comments  路  Source: rt2zz/redux-persist

I'm getting this error while building nw.js chromium app with this index.js

webpack:///./~/redux-persist/lib/persistStore.js?:49 Uncaught ReferenceError: setImmediate is not defined

I thought setImmediate was not supported natively in most of browsers.

import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router } from 'react-router';
import routes from './routes';
import configureStore from './store/configureStore';
import './app.css';

import {persistStore, autoRehydrate} from 'redux-persist'


const store = configureStore();

persistStore(store);

render(
  <Provider store={store}>
    <Router>
      {routes}
    </Router>
  </Provider>,
  document.getElementById('root')
);

Most helpful comment

On a fresh install I ran into this issue, it might be a good idea to mention this in the docs.

The fix:

npm install setimmediate
import 'setimmediate';
import { persistStore } from 'redux-persist';

All 5 comments

Well, l didn't know that within a certain framework setImmediate is not automatically provided by global.setImmediate().
I sent a PR.

accepted (with some modification) can you test on master to see if it is working as anticipated: npm install rt2zz/redux-persist

Doesn't work. Solution was to
npm install setimmediate
and use
import setimmediate from 'setimmediate';

Works like a charm.
Had to do npm run buildat the folder though.

@noma4i the setImmediate shim was only effective when you don't have global.setImmediate already. ?

On a fresh install I ran into this issue, it might be a good idea to mention this in the docs.

The fix:

npm install setimmediate
import 'setimmediate';
import { persistStore } from 'redux-persist';
Was this page helpful?
0 / 5 - 0 ratings