【问题标题】:ESLint warning; defined but never used for react-native components [duplicate]ESLint 警告;已定义但从未用于 react-native 组件 [重复]
【发布时间】:2018-07-14 07:54:25
【问题描述】:

它显示已定义但从未用于导入的组件;即使使用了该组件。如何忽略这个 eslint 警告?

例如:

import { Provider } from 'react-redux';

....

并在渲染函数中添加

render(){
<Provider store={appStore}>
 ......
</Provider>
}

它显示的 Provider 已定义但未使用。任何帮助将不胜感激。 谢谢,

【问题讨论】:

    标签: react-native eslint


    【解决方案1】:

    我终于解决了,这里是解决办法;

    首先,安装 eslint-plugin-react 并在 .eslintrc.json 文件中进行更改。

     {
    ...
    "extends": [
            "eslint:recommended",
            "plugin:react/recommended"
        ],
    ...
    }
    

    解决方案来源: https://github.com/babel/babel-eslint/issues/6

    【讨论】:

      猜你喜欢
      • 2023-01-07
      • 2018-01-06
      • 1970-01-01
      • 2019-02-20
      • 1970-01-01
      • 1970-01-01
      • 2020-12-17
      • 2023-02-22
      • 2018-12-29
      相关资源
      最近更新 更多