gpt4 book ai didi

reactjs - "Attempted import error: ' authReducer ' is not exported from ' ./authReducer '. "

转载 作者:行者123 更新时间:2023-12-05 09:13:11 25 4
gpt4 key购买 nike

**实际上,我正在尝试从名为 authReducer.js 的 JS 文件导入一个函数,但我无法这样做。

在 authReducer.js 中,我尝试将该函数以 authReducer 的名称存储在 const 变量中,然后尝试将其导出,但仍然出现相同的错误

index.js

import {combineReducers} from 'redux'

import {authReducer} from './authReducer' //I'm getting error here

export default combineReducers({
auth:authReducer
});

authReducer.js

const initialState={
isAuthenticated:false,
user:{}
}


export default function(state=initialState,action){
switch(action.type)
{
default:
return state;
}
};

两者都位于同一个文件夹中。

最佳答案

更改导入自:

import { authReducer } from './authReducer'

到:

import authReducer from './authReducer`'

关于reactjs - "Attempted import error: ' authReducer ' is not exported from ' ./authReducer '. ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56609496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com