[英]Objects are not valid as a React child Error in next js
I use the latest version next js inside my project.我在我的项目中使用最新版本的 next js。 Recently I faced objects not valid as a react js child error.
最近我遇到了对象无效作为 react js 子错误。
First import Head components are next js, and after I use SEO schema structure in the project, I face an error.先import Head组件,next js,我在项目中使用SEO schema结构后,报错。 Please guide me on how to resolve this issue.
请指导我如何解决这个问题。 I also use {} in a script tag inside and outside, but not working for me.
我还在内部和外部的脚本标签中使用 {},但对我不起作用。
<Head>
<title>Random color project </title>
<meta
name="description"
content="Random Color tool help to genrate random color base on your click. every time when you click on button random color genrate a color "
/>
{/* rest code */}
{/* SEO Schema structure code for search egine */}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
image: ["https://avatars2.githubusercontent.com/u/32416397"],
author: {
"@type": "Person",
name: "Rajdeep Singh"
},
....
}
</script>
</Head>
Try below instead of your script with the object.尝试下面而不是您的脚本与对象。
<script type='application/ld+json' dangerouslySetInnerHTML={ { __html: `{
"@context": "https://schema.org",
"@type": "WebSite",
image: ["https://avatars2.githubusercontent.com/u/32416397"],
author: {
"@type": "Person",
name: "Rajdeep Singh"
},
....
}`}}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.