为什么要导入存储未定义?

时间:2019-06-23 17:24:40

标签: javascript reactjs redux

当我console.log然后发现undefined时,我试图从存储中获取用于设置默认令牌axios的状态。

this is image about folder structure

这是我的代码axiosConfig.js:

import axios from 'axios'
import _ from 'lodash'
const BASE_URL = '********.com'
import store from '../store'
console.log('store', store)

const instance = axios.create({
    baseURL: BASE_URL
})

export { instance }

这是我的代码store.js:

import { createStore, applyMiddleware } from 'redux'
import 'regenerator-runtime/runtime'
import createSagaMiddleware from 'redux-saga'
import rootSaga from './sagas'
import rootReducer from './reducers/index'
import { routerMiddleware } from 'react-router-redux'
import { createBrowserHistory } from 'history'
import logger from 'redux-logger'

export const history = createBrowserHistory()

export const defaultState = {}

const sagaMiddleware = createSagaMiddleware()

const store = createStore(rootReducer, defaultState, applyMiddleware(sagaMiddleware, routerMiddleware(history)))

sagaMiddleware.run(rootSaga)

export default store

错误:

store undefined

0 个答案:

没有答案