在我正在构建的 React Web 应用程序中,据说可能忘记导出一个组件。但是在检查代码时,导入和导出似乎很好
由于我现在只使用转储组件,因此我尝试将它们定义为不同的方式,例如使用粗箭头函数,但没有成功。
以下是 Navbar 的片段 - SignIn 和 SignOut 组件也以与导航栏相同的方式声明:
import React from 'react';
import { Link } from 'react-router-dom'
import SignInLink from './SignInLink'
import SignOutLink from './SignOutLink'
const Navbar = () => {
return (
<nav className="z-depth-10 black">
<div className="nav-wrapper container">
< Link to="/" className="brand-logo">Lelo's</Link>
<SignInLink />
<SignOutLink />
</div>
</nav>
)
}
export default Navbar
编译后,我从浏览器得到这个:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports
一只名叫tom的猫
相关分类