是否缺少nextjs 12.1.0中具有Reaction 18的数组中元素的&q;键&prop? [英] Missing "key" prop for element in array in nextjs 12.1.0 with react 18?
本文介绍了是否缺少nextjs 12.1.0中具有Reaction 18的数组中元素的&q;键&prop?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用npx create-next-app
创建了一个下一个js应用程序。但当我尝试使用Runningnpm-run-build
进行构建时。它会给出错误。这里的下一个版本是12.1.0,Reaction版本是18。但当我在下一个旧版本中使用相同的代码时,比如12.0.10,大概是这样的。那么它就不会给出错误。我认为这是下一个JS更新版本的变化。但我做了什么?
错误就像它-
以下是index.js代码-
import Head from 'next/head'
import Image from 'next/image'
import styles from '../styles/Home.module.css'
export default function Home() {
return (
<div className={styles.container}>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>
<p className={styles.description}>
Get started by editing{' '}
<code className={styles.code}>pages/index.js</code>
</p>
<div className={styles.grid}>
<a href="https://nextjs.org/docs" className={styles.card}>
<h2>Documentation →</h2>
<p>Find in-depth information about Next.js features and API.</p>
</a>
<a href="https://nextjs.org/learn" className={styles.card}>
<h2>Learn →</h2>
<p>Learn about Next.js in an interactive course with quizzes!</p>
</a>
<a
href="https://github.com/vercel/next.js/tree/canary/examples"
className={styles.card}
>
<h2>Examples →</h2>
<p>Discover and deploy boilerplate example Next.js projects.</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
>
<h2>Deploy →</h2>
<p>
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
</div>
</main>
<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{' '}
<span className={styles.logo}>
<Image src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
</span>
</a>
</footer>
</div>
)
}
此代码正是创建下一个应用程序时的模板代码。我在这里不做任何更改。
推荐答案
这看起来像是eslint中的一个错误,其他用户通过降级到以前的版本(eslint-plugin-action从7.29.0到7.28.0)解决了这个问题。github.com/yannickcr/eslint-plugin-react/issues/3215-或者您也可以更改配置,以便在构建nextjs应用程序时忽略ESLint-nextjs.org/docs/api-reference/next.config.js/ignoring-eslint
这篇关于是否缺少nextjs 12.1.0中具有Reaction 18的数组中元素的&q;键&prop?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文