User.tsx是一种导航栏,它通过{props.children}传递所有子组件。我还想向它传递一个breadcrumb组件,但我收到一个错误消息:
JSX元素类型“prop.component”没有任何构造或调用签名
Layout.tsx:
import UserShell from "./account/User
import Breadcrumb from "./navigation/Breadcrumb";
<User component={Breadcrumb}>{props.children}</User>;
User.tsx:
type ShellProps = {
children: React.ReactNode | React.ReactNode[];
component?: React.ComponentType;
export default function UserShell(props: ShellProps) {
return (
<>
<props.component />
^^^^^^^^^^^^^^^^^^//error is here
<div>{props.children}</div>
</>
}
有什么解决办法吗?
2条答案
按热度按时间xytpbqjk1#
运动场
您可能需要大写组件(Component)
sbtkgmzw2#
尝试更新到此
Layout.tsx:
User.tsx