ESLint/eslint-plugin-react:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 标题文字 == == error == * function React.forwardRef<any, {}>(render: React.ForwardRefRenderFunction<any, {}>): React.ForwardRefExoticComponent<React.RefAttrib…”
 
Kangkk​(留言 | 贡献)
 
(未显示同一用户的3个中间版本)
第1行: 第1行:
== 标题文字 ==
== 标题文字 ==
== error ==
== error ==
* function React.forwardRef<any, {}>(render: React.ForwardRefRenderFunction<any, {}>): React.ForwardRefExoticComponent<React.RefAttributes<any>>
* <syntaxhighlight lang="javascript" inline>
Component definition is missing display nameeslintreact/display-name
function React.forwardRef<any, {}>(render: React.ForwardRefRenderFunction<any, {}>): React.ForwardRefExoticComponent<React.RefAttributes<any>></syntaxhighlight> Component definition is missing display nameeslintreact/display-name
: 组件定义缺少显示名称
: <syntaxhighlight lang="javascript">
: <syntaxhighlight lang="javascript">
const Test = React.forwardRef(function Input(props, ref) { return <input {...props} />});</syntaxhighlight>
const Test = React.forwardRef(function Input(props, ref) { return <input {...props} />});</syntaxhighlight>
第9行: 第10行:
const Test = React.forwardRef((props, ref) => { return <input {...props} />});
const Test = React.forwardRef((props, ref) => { return <input {...props} />});
Test.displayName = 'Test';</syntaxhighlight>
Test.displayName = 'Test';</syntaxhighlight>
* React version not specified in eslint-plugin-react settings. See https://github.com/yannickcr/eslint-plugin-react#configuration .
: 在eslintrc.js或者.eslintrc文件中添加配置项:
: <syntaxhighlight lang="javascript">
"settings": {
  "react": {
    "version": "detect"
  }
}</syntaxhighlight>

2022年6月6日 (一) 04:56的最新版本

标题文字

error

  • function React.forwardRef<any, {}>(render: React.ForwardRefRenderFunction<any, {}>): React.ForwardRefExoticComponent<React.RefAttributes<any>> Component definition is missing display nameeslintreact/display-name
组件定义缺少显示名称
const Test = React.forwardRef(function Input(props, ref) { return <input {...props} />});
or
const Test = React.forwardRef((props, ref) => { return <input {...props} />});
Test.displayName = 'Test';
在eslintrc.js或者.eslintrc文件中添加配置项:
"settings": {
  "react": {
    "version": "detect"
  }
}