我在从对象渲染组件时出现错误.
ype 'FC<Boxprops> | ExoticComponent<{ children?: ReactNode; }>' is not assignable to type 'FC<Boxprops>'.
Type 'ExoticComponent<{ children?: ReactNode; }>' is not assignable to type 'FunctionComponent<Boxprops>'.
我正在try 在对象键的基础上呈现组件
import "./styles.css";
import { BOX, Boxprops } from './box'
import React from "react";
let obj = {
component:'box'
}
export default function App() {
const getComponnets = () => {
let Component: React.FC<Boxprops> = obj.component === 'box' ? BOX : React.Fragment
return <Component title="asd" />
}
return (
<div className="App">
{getComponnets()}
</div>
);
}
以下是我的代码 https://codesandbox.io/s/naughty-fermat-szgggm?file=/src/App.tsx个
有什么 idea 吗..??