Javascript Can';无法让React-redux使用redux-persist

Javascript Can';无法让React-redux使用redux-persist,javascript,react-redux,redux-persist,Javascript,React Redux,Redux Persist,您好,我正在尝试使用react-redux设置redux persist,但我无法让它工作。我得到以下错误: TypeError:_store2.default不是函数[Learn More]索引。js:12:29 我现在如何进行设置: store.js import {applyMiddleware, createStore} from 'redux'; import {persistStore,persistCombineReducers} from 'redux-persist'; imp

您好,我正在尝试使用react-redux设置redux persist,但我无法让它工作。我得到以下错误:

TypeError:_store2.default不是函数[Learn More]索引。js:12:29

我现在如何进行设置:

store.js

import {applyMiddleware, createStore} from 'redux';
import {persistStore,persistCombineReducers} from 'redux-persist';
import storage from 'redux-persist/es/storage' // default: localStorage if web, AsyncStorage if react-native

import { logger } from 'redux-logger';
import thunk from 'redux-thunk';
import promise from 'redux-promise-middleware';
import reducer from './reducers'

const middleware = applyMiddleware(promise(), thunk, logger);

const config = {
  key: 'root',
  storage,
};

const reducers = persistCombineReducers(config, {reducer});

export const configureStore = () => {
  const store = createStore(reducers, middleware);
  const persistor = persistStore(store);
  return { persistor, store };
};
index.js

import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter} from 'react-router-dom';
import {Provider} from 'react-redux';
import Bootstrap from 'bootstrap/dist/css/bootstrap.css';
import './css/app.css';
import App from './containers/App';

import { PersistGate } from 'redux-persist/es/integration/react'
import configureStore from './store';
const { persistor, store } = configureStore()


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

如果要使用默认导出,则需要更改:

export const configureStore = () => {
  const store = createStore(reducers, middleware);
  const persistor = persistStore(store);
  return { persistor, store };
};
致:

或:

或者,如果不想使用默认导出更改:

import configureStore from './store';
致:


因此,经过一番思考和社区帮助,我设法将问题缩小到我的声明中。我在index.js中用combinereducer声明reducer,而redux persist说不应该这样

Final index.js代码:

import user from './userReducer'
import auth from './authReducer'

export default ({
  user, auth
})

谢谢,我试过了,但不是说我调用它时没有定义“store”:@connect((store)=>{return{isAuthenticated:store.auth.isAuthenticated,};})签出更新1
const configureStore = () => {
  const store = createStore(reducers, middleware);
  const persistor = persistStore(store);
  return { persistor, store };
};

export default configureStore;
import configureStore from './store';
import { configureStore } from './store';
import user from './userReducer'
import auth from './authReducer'

export default ({
  user, auth
})