Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

reactjs - I am having error of "property 'subscribe' of undefined" in the PersistGate- react redux

I am getting this error "TypeError: Cannot read property 'subscribe' of undefined". I looked in StackOverflow and find many questions like this one, but none of them provide a solution that solves this issue. I hope if someone tells me what wrong with it. enter image description here

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import * as serviceWorker from './serviceWorker';
import { Provider } from 'react-redux';
import {PersistGate} from 'redux-persist/integration/react';
import App from './App';
import {store} from './Components/redux/store.js'
import {persistore} from './Components/redux/store.js'
import 'bootstrap/dist/css/bootstrap.min.css';
import './index.css';
import './Components/fonsts/AnonymousPro-Bold.ttf'

ReactDOM.render(
  <React.StrictMode>
    <Provider store={store}>
      <PersistGate  persistore={persistore}>
      <App />
      </PersistGate>
    </Provider> 
  </React.StrictMode>,
  document.getElementById('root')
);

store.js

import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunkMiddleWare from 'redux-thunk';
import { composeWithDevTools } from 'redux-devtools-extension';
import { searchItemsReducer, requestSearchItemsReducer, requestUserLoginReducer } from './Reducers.js';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';

const persistConfig = {
  key: 'root',
  storage: storage,
  whitelist: ['requestUserLoginReducer']
};

const rootReducers = combineReducers({
  searchItemsReducer,
  requestSearchItemsReducer,
  requestUserLoginReducer
});

const middleware = composeWithDevTools(applyMiddleware(thunkMiddleWare));
const pReducer = persistReducer(persistConfig, rootReducers);

export const store = createStore(pReducer, middleware);

export const persistore = persistStore(store);

I initialize the state in the reducer.js Thank you


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...