Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: display-name false positive when React is shadowed #3924

Open
@knightedcodemonkey

Description

@knightedcodemonkey

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

react/display-name will report an errorComponent definition is missing display name when theReact global import is shadowed within a function scope.

The same error does not occur for shadowedmemo orforwardRef though.

Example

importReact,{memo,forwardRef}from'react'constMixedShadowed=function(){constmemo=(cb)=>cb()const{ forwardRef}={forwardRef:()=>null}const[React]=[{ memo, forwardRef}]constComp=memo(()=>{return<div>shadowed</div>})constReactMemo=React.memo(()=>null)constReactForward=React.forwardRef((props,ref)=>{return`${props}${ref}`})constOtherComp=forwardRef((props,ref)=>`${props}${ref}`)return[Comp,ReactMemo,ReactForward,OtherComp]}

Running eslint from the command line you'll see the error:

  11:21  error  Component definition is missing display name  react/display-name  12:24  error  Component definition is missing display name  react/display-name

Expected Behavior

I know most people won't shadowReact,memo orforwardRef, but I'd still expect the error to not be reported in this case.

eslint-plugin-react version

v7.37.5

eslint version

v9.26.0

node version

v22.15.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp