mapStateToProps当使用redux-immutable时道具为空

时间:2019-01-11 08:02:26

标签: javascript reactjs redux serverside-rendering

我正在开发ReactJs SSR应用程序。

client.js

import React from 'react';
import {hydrate} from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import { createStore, applyMiddleware } from 'redux';

const axiosInstance = axios.create({
  baseURL: BASE_URL
});

const initialState = fromJS(window.__INITIAL_STATE__) ;

const Store = createStore(
  reducers,
  initialState,
  applyMiddleware(thunk.withExtraArgument(axiosInstance))
);

hydrate(  
  <Provider store={Store}>
    <BrowserRouter>
      <div>
        {Localstore.get("menu")&&
        <Menu categories={Localstore.get("menu")} />}
        {renderRoutes(Routes)}        
      <Footer />
      </div>      
    </BrowserRouter>  

  </Provider>,
  document.querySelector('#root')
);

当我将initialState传递给createStore时,我的redux-modal正在工作,但是mapStateToProps为空。 当我将window.INITIAL_STATE传递给createStore时,mapStateToProps显示道具但模态不起作用并显示波纹管错误

  

TypeError:state.merge不是函数

0 个答案:

没有答案