Home > Software engineering >  Error: Missing "key" prop for element in array react/jsx-key
Error: Missing "key" prop for element in array react/jsx-key

Time:03-04

When I try to build my next.js app, I'm receiving the following error: Error: Missing "key" prop for element in array react/jsx-key in every component: enter image description here

I only use the map function once in my project and did put the key prop: enter image description here

And I cannot understand why I'm getting that error, not that at I also got the following error at the end: enter image description here

CodePudding user response:

Pass key={index} prop to RightPackage instead of sending to div

CodePudding user response:

It seems, you need to pass key props in the RightPackage component.

{rightPackages.map((item, index) => (
  <div key={`right-package${index`}>
    <RightPackage key={index.toString()} />
</div>

) )}

or you can pass if item is having any unique id.

CodePudding user response:

It turned out that the solution was to disable eslint, This can be done by going to next.config.js file and adding the following:

eslint: {
        ignoreDuringBuilds: true,
    },

like this:

/** @type {import('next').NextConfig} */
const nextConfig = {
    reactStrictMode: true,
    eslint: {
        ignoreDuringBuilds: true,
    },
};

module.exports = nextConfig;

  • Related