Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsx-key Missing "key" prop for element in array when there is no array/iteration #3215

Closed
alicerocheman opened this issue Feb 25, 2022 · 49 comments

Comments

@alicerocheman
Copy link

Hello,

I just upgraded eslint-plugin-react from 7.28.0 to 7.29.0

The result is I now get a Missing "key" prop for element in array error on all my components, regardless of them having an array/map or anything that would require a key prop.

Before upgrade, the app worked fine, the key prop was already where it should be, on all arrays/lists.

Example of error:

  17:7  error  Missing "key" prop for element in array  react/jsx-key

Screenshot 2022-02-25 at 08 29 31

=> no array on line 17 char 7, just calling a component.

@erikpukinskis
Copy link

erikpukinskis commented Feb 25, 2022

I can confirm I'm seeing this with [email protected] downgrading to 7.28.0 the error goes away.

@martinstark
Copy link

Same, does not look right. Several hundred errors. Some lines trigger this error multiple times.

@yoyo837
Copy link
Contributor

yoyo837 commented Feb 25, 2022

Same here.
image

@DominicLi77
Copy link

I also encountered the same problem, it can be solved by downgrading the version

@shiftj18
Copy link

shiftj18 commented Feb 25, 2022

+1,expect it rollback to 7.28.0.

image
image

@awmleer
Copy link

awmleer commented Feb 25, 2022

Wondering why there is no release log about 7.29.0 on the releases page. 🤔

@kliehm
Copy link

kliehm commented Feb 25, 2022

I do use keys, but of course only for the outmost element. This new rule requires a key for every child element, too. I think this is an error. In the following example the rule throws an error that the div element doesn't have a key attribute. That's wrong.

{this.myArray.map((item) => (
  <li key={item.id}>
    <div>foo</div>
  </li>
)

@shrijan00003
Copy link

Wondering why there is no release log about 7.29.0 on the releases page. 🤔

True!,

kodiakhq bot pushed a commit to vercel/next.js that referenced this issue Feb 25, 2022
Fixes #34797.

Context: https://github.com/yannickcr/eslint-plugin-react was released in 7.29.0 2h ago and breaks the linting of a default create-next-app.

See: jsx-eslint/eslint-plugin-react#3215

This PR locks the version to the latest working one.
@cojoclaudiu
Copy link

I confirm same issue, I'm using vite with React TypeScript

@sanjeevkpandit
Copy link

Facing the same with React.

@briantuju
Copy link

Just installed a new project using npx create-next-app and I'm getting the exact same error

Robbert added a commit to nl-design-system/utrecht that referenced this issue Feb 25, 2022
Avoided installing [email protected].
A bug in this version resulted in hundreds of false positives.
jsx-eslint/eslint-plugin-react#3215
mmomtchev added a commit to mmomtchev/rlayers that referenced this issue Feb 25, 2022
@mustafasavul
Copy link

We are currently getting the same error in bitbucket pipelines.

When installed with yarn, the package eslint-plugin-react goes up to 7.29.

It gives error like this.

When we do npm install, it does not give an error. Because it stays at 7.28.

Robbert added a commit to nl-design-system/utrecht that referenced this issue Feb 25, 2022
Avoided installing [email protected].
A bug in this version resulted in hundreds of false positives.
jsx-eslint/eslint-plugin-react#3215
@ljharb

This comment was marked as resolved.

@AnselmoMartins

This comment was marked as resolved.

@altuno

This comment was marked as resolved.

@ljharb

This comment was marked as resolved.

@ljharb

This comment was marked as resolved.

@jukialen
Copy link

Hey, I tried to find eslint-config-next repositories, because I have the same bug. I updated this and next to latest stable and canary version, but it didn't help. What do you know something about this?

@altuno

This comment was marked as resolved.

@ljharb
Copy link
Member

ljharb commented Feb 25, 2022

@jukialen please file a new issue if you're still having problems.

ijjk added a commit to vercel/next.js that referenced this issue Feb 26, 2022
* Update eslint-plugin-react to latest version

There is currently a bug in eslint-plugin-react jsx-eslint/eslint-plugin-react#3215.
The bug was just fixed in 7.29.1

* update lockfile

Co-authored-by: JJ Kasper <[email protected]>
@DanielBailey-web
Copy link

Just a quick heads up to anyone still experiencing this after upgrading. You may have to delete your .next folder after upgrading to 7.29.1

@jukialen
Copy link

Just a quick heads up to anyone still experiencing this after upgrading. You may have to delete your .next folder after upgrading to 7.29.1

I only add that if someone has only next and eslint-config-next in a package.json, and updating next canary version won't help, it schould delete .next folder, reopen a project and install eslint-plugin-react in 7.29.1 (in this order). It helped me so maybe it'll help someone.

@hraboviyvadim

This comment was marked as spam.

@jukialen

This comment was marked as resolved.

@theabhayprajapati

This comment was marked as spam.

@jukialen

This comment was marked as resolved.

@cojoclaudiu

This comment was marked as resolved.

werkshy added a commit to werkshy/pickup that referenced this issue Feb 27, 2022
The upgrade to 7.29.0 had [a
bug](jsx-eslint/eslint-plugin-react#3215) that
flagged a lot of false positives. Upgrading to 7.29.2 to pull in the
fix.
werkshy added a commit to werkshy/pickup that referenced this issue Feb 27, 2022
The upgrade to 7.29.0 had [a
bug](jsx-eslint/eslint-plugin-react#3215) that
flagged a lot of false positives. Upgrading to 7.29.2 to pull in the
fix.
@ancashoria

This comment was marked as resolved.

@shaharyar007
Copy link

I know it's a bit late, as many of you found the solution probably but I want to add my experience,i was facing the same problem but then I used React fragment (<></>) and the error was removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests