gpt4 book ai didi

reactjs - ESLint 首选默认导出导入/prefer-default-export

转载 作者:行者123 更新时间:2023-12-03 13:32:40 25 4
gpt4 key购买 nike

您好,我正在努力理解/让这个 eslint 错误在我的 React 项目中消失。

首选默认导出导入/prefer-default-export

Helpers.js 错误指向:

export function getItems() {
fetch('./data/data_arr.js')
.then(results => results.json())
.then(results => this.setState({ items: results }));
}

导入函数:

从 '../helpers/helpers' 导入 { getItems };

componentDidMount() {
getItems.call(this);
}

我已经尝试过,但没有成功:

"rules": {
"import/prefer-default-export": off,
...
}

我需要在函数中添加“默认”吗? 导出默认函数 getItems() {...}

谢谢

最佳答案

"rules": {
"import/prefer-default-export": "off",
...
}

单词off必须被引用。

关于reactjs - ESLint 首选默认导出导入/prefer-default-export,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52627477/

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