0
當運行通過的WebPack開發服務器我的服務器,我得到這個錯誤:的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')
);
正確地在服務器端呈現一切,問題是當我在客戶端有這個路由器代碼。似乎路由器正在試圖像服務器大小的路由器那樣工作,即使它正在客戶端上運行。
我使用的版本是:
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
我將此設置爲接受的答案,因爲它將我引向正確的解決方案。謝謝! 實際的解決方案是我導入和發送的歷史記錄不正確。我需要從'react-router/lib/BrowserHistory'中抓取'BrowserHistory'(你不知道我給你的信息) –
太棒了!我很高興你能工作! –