サーバーを webpack dev サーバーを介して実行すると、次のエラーが発生します。
Uncaught Error: Invariant Violation: Server-side <Router>s need location,
branch, params, and components props. Try using Router.run to get all the
props you need
クライアント エントリ ファイルは次のようになります。
// ... imports ...
let initialState = window.__INITIAL_STATE__;
Object.keys(initialState)
.forEach(key => {
initialState[key] = fromJS(initialState[key]);
});
const reducer = combineReducers(reducers);
const store = createStore(reducer, initialState);
React.render(
<Provider store={store}>
{() =>
<Router children={routes} history={history} />
}
</Provider>,
document.getElementById('react-view')
);
すべてがサーバー側で正しくレンダリングされます。問題は、このルーター コードがクライアント側にある場合です。クライアント上で実行されているにもかかわらず、ルーターがサーバーサイズのルーターのように機能しようとしているようです。
私が使用しているバージョンは次のとおりです。
├── react@0.13.3
├── react-hot-loader@1.3.0
├── react-redux@0.8.2
├── react-router@1.0.0-beta3
├── redux@1.0.1
└── webpack-dev-server@1.10.1