ReactJS Redux Persist 没有显示我的化简器



由于某种原因-当我控制台.log(this.props(时,我看不到我的减速器。每次重新加载应用程序时,我都会进行清除,以重置当前的减速器状态。我甚至无法查看INITIAL_STATE默认值。下面是我的HOC,包含路由器、提供者和持久门。还有reducers(reducer/index.js(和存储配置文件(store/index.js(

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import {store, persistor} from './store/index';
import { PersistGate } from 'redux-persist/integration/react';
import App from './App';
import './i18n';
persistor.purge()
console.log("purged")
ReactDOM.render(
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<App/>
</PersistGate>
</Provider>, 
document.getElementById('app')
);

store/index.js

import { createStore, applyMiddleware } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web and AsyncStorage for react-native
import rootReducer from '../reducers/index'
const persistConfig = {
key: 'primary',
storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
const middleware = applyMiddleware()
const store = createStore(
persistedReducer,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
middleware
)
const persistor = persistStore(store)
export {store, persistor}

减速器/index.js

import storage from 'redux-persist/lib/storage';
export const SETJWT = 'auth/login/setJWT'
let INITAL_STATE = {
JWT: 'testJWT',
currentUser: null,
isLoggingIn: false
}
const rootReducer = (state = INITAL_STATE, action) => {
switch(action.type){
case SETJWT:
return {...state, JWT: action.payload};
default:
return state;
}
}
export default rootReducer

我需要将以下内容添加到我的createstore 中

combineReducers({
state: persistedReducer
}),

最新更新