我正在开发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不是函数