简体   繁体   English

NextJS:错误 - 元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object

[英]NextJS: error - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object

I am getting this error我收到这个错误

error - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.错误 - 元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:object。

My \components\LayoutWrapper.js我的\components\LayoutWrapper.js

import Logo from "@next/svg"

<div className="mr-3 pt-2">
  <Logo src={icon} width="25px" height="25px" />
  {typeof siteMetadata.headerTitle === 'string' ? (
    <div className=""></div>
  ) : (
    siteMetadata.headerTitle
  )}
</div>

Fixed and working固定和工作

import Image from 'next/image'
import logo from '../assets/images/logo.svg'

<div className="mr-3 pt-2">
  <Image src={logo} width="25px" height="25px" />
  {typeof siteMetadata.headerTitle === 'string' ? (
    <div className=""></div>
  ) : (
    siteMetadata.headerTitle
  )}
</div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件)但得到:ReactJS 中的对象 - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object in ReactJS 错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:对象 - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object × 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object - × Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object Webpack:错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object - Webpack: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object NextJS:元素类型无效:期望字符串(用于内置组件)或类/函数(用于复合组件)但得到:未定义 - NextJS: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义。 在 nextjs 中 - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. in nextjs 不变违规:元素类型无效:预期为字符串(内置组件)或类/函数(复合组件),但得到:对象 - Invariant Violation: Element type is invalid: expected a string (built-in components) or a class/function (composite components) but got: object 元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:object。abcd - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. abcd Material UI - 元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object - Material UI - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object 错误 - 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - error - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM