v2.0.0
Breaking Changes
Hot reloading reducers is now explicit (#80)
React Redux used to magically allow reducer hot reloading. This magic used to cause problems (reduxjs/redux#301, reduxjs/redux#340), so we made the usage of replaceReducer()
for hot reloading explicit (reduxjs/redux#667).
If you used hot reloading of reducers, you'll need to add module.hot
API calls to the place where you create the store. (Of course, assuming that you use Webpack.)
Before
import { createStore } from 'redux';
import rootReducer from '../reducers/index';
export default function configureStore(initialState) {
return createStore(rootReducer, initialState);
}
After
import { createStore } from 'redux';
import rootReducer from '../reducers/index';
export default function configureStore(initialState) {
const store = createStore(rootReducer, initialState);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextRootReducer = require('../reducers/index');
store.replaceReducer(nextRootReducer);
});
}
return store;
}
This is more code, but what's happening is now explicit, and this also lets you do this right in index.js
instead of creating a separate <Root>
component. See reduxjs/redux#667 for a migration example.
process.env.NODE_ENV
is required for CommonJS build (#81)
In 0.7.0, we temporarily removed the dependency on it to support React Native, but now that RN 0.10 is out with process.env.NODE_ENV
polyfill, we again demand it to be defined. If you're not ready to use RN 0.10, or are in a different environment, either use a browser build, or shim it yourself.