我正在尝试组合减速器
文件夹结构
src
reducers
authReducer.js
lojaReducer.js
index.js
我正在Index.js导入
import {lojaReducer, authReducer} from './reducers';
import { persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import { combineReducers } from 'redux';
const authPersistConfig = {
key: 'auth',
storage: storage,
blacklist: ['somethingTemporary']
}
export const Reducers = combineReducers ({
authState: persistReducer(authPersistConfig, authReducer),
lojaState: lojaReducer
});
但是我遇到了错误
Module not found: Can't resolve './reducers'
当我仅使用lojaReducer时,如何导入多个reducer?
答案 0 :(得分:2)
由于reducer位于单独的文件中,因此您需要分别导入它们。
类似的东西:
import authReducer from './authReducer'
import lojaReducer from '. /lojaReducer'
或
import { authReducer} from './authReducer'
import { lojaReducer} from './lojaReducer'
取决于将它们定义为export
还是export default