我已经设置了服务器端渲染。但是,调用 store.getstate() 的 server.js 中的代码仅获取我的默认初始状态,而不是客户端的状态。我怎样才能解决这个问题?
Server.js: http://pastebin.com/u31cqaUh
配置存储:http: //pastebin.com/7FXV6NDS
根.js:
import React, {Component} from 'react';
import {Provider} from 'react-redux';
import configureStore from './store/configureStore';
import {Router, Route, hashHistory, browserHistory} from 'react-router';
import { syncHistoryWithStore, routerReducer } from 'react-router-redux';
import Routes from '../routes';
const store = configureStore(window.__INITIAL_STATE__);
delete window.__INITIAL_STATE__;
const history = syncHistoryWithStore(browserHistory, store)
export default class Root extends Component {
render() {
return (
<Provider store={store}>
<Router history={history} routes={Routes}>
</Router>
</Provider>
)
}
}