Redux getstate总是返回初始状态?

时间:2016-07-01 18:15:03

标签: javascript reactjs redux serverside-rendering

我已经设置了服务器端渲染。但是,调用store.getstate()的server.js中的代码只获取我的默认初始状态而不是客户端的状态。我该如何解决这个问题?

Server.js: http://pastebin.com/u31cqaUh

Configurestore: http://pastebin.com/7FXV6NDS

Root.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>
        )
    }
}

0 个答案:

没有答案