こんにちは、私はreactxを使ってredux-persistを設定しようとしていますが、動作させることはできません。私は今セットアップしたかredux-persistxで動作するようにReact-reduxを取得できません
TypeError: _store2.default is not a function [Learn More] index.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')
);
UPDATE 1
@のaziumの応答に基づいては、今私が取得:
The above error occurred in the component: in Connect(App) (created by Route) in Route (created by withRouter(Connect(App))) in withRouter(Connect(App)) in Router (created by BrowserRouter) in BrowserRouter in PersistGate in Provider
App.jsからそうのようにそれを呼び出す場合:
@withRouter
@connect((store) => {
return {
isAuthenticated: store.auth.isAuthenticated,
};
})
おかげで、私はそれを試してみましたが、私はそれを呼び出すときに "ストア" が定義されていないと言うではない:@connect((ストア)=> { リターン{ にisAuthenticated :store.auth.isAuthenticated、 }; }) 更新を確認する1 – galgo