![](/img/trans.png)
[英]webpack-dev-server with redux and react is blocking my inputs
[英]Webpack-dev-server, redux, isomorphic react router invariant error
通過webpack開發服務器運行服務器時,出現以下錯誤:
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
服務器交付第一頁后,您仍然需要在客戶端調用Router.run
來處理導航。 它將使用Router.HistoryLocation
並仍然為匹配的路由執行React.render
方法。 嘗試調用React.render
的內部Router.run
,而不是周圍的其他方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.