rackt/react-router — pull request #384 by gaearon (2014-10-10 20:25:04+00:00)
Title: Fix redirect and fire onChange when rendering for the first time

Fixes #360 and `onChange` not firing on initial render.

Explanation:

1. #360 was caused by `PathStore` emitting change that nobody listened to yet. I fixed it by moving subscription to `componentWillMount` right before triggering `updateLocation` (which itself may trigger the redirect).

2. `onChange` not firing was caused by [this problem in `ReactCompositeComponent`](https://github.com/facebook/react/blob/master/src/core/ReactCompositeComponent.js#L900) (cc @spicyj), basically `setState`'s current implementation ignores callback if it is called while mounting, so it never fired. As a workaround, I save it and fire in `componentDidMount`.