@gaearon gaearon released this Sep 1, 2015 · 1662 commits to master since this release

Assets 2

Breaking Changes

getReducer() is removed from Store public API (https://github.com/rackt/redux/pull/668)

It was only needed because React Redux used it to magically allow reducer hot reloading. This magic used to cause problems (https://github.com/rackt/redux/issues/301, https://github.com/rackt/redux/issues/340), so we made the usage of replaceReducer() for hot reloading explicit (https://github.com/rackt/redux/pull/667).

It is likely that you never used getReducer(). However, 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 https://github.com/rackt/redux/pull/667 for a migration example.

compose() now acts like a proper compose() (#669)

This fixes the embarrassing mishap that compose() API was.
As suggested by @jlongster, now it is a proper compose() you'd find in Lodash or Underscore:

it('composes from right to left', () => {
  const double = x => x * 2;
  const square = x => x * x;
  expect(compose(square)(5)).toBe(25);
  expect(compose(square, double)(5)).toBe(100);
  expect(compose(double, square, double)(5)).toBe(200);
});

In terms of usage, you just need to remove createStore from the chain, and add it as a function application instead.

Before

const finalCreateStore = compose(
  applyMiddleware(stuff),
  devTools(),
  somethingElse(),
  createStore
);

After

const finalCreateStore = compose(
  applyMiddleware(stuff),
  devTools(),
  somethingElse()
)(createStore);

process.env.NODE_ENV is required for CommonJS build (https://github.com/rackt/redux/pull/671)

In 1.0.1, 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.