reactjs - 如何从 TypeScript 中的字符串名称动态构建元素?
问题描述
我有以下代码:
interface StyledTypographyProps extends TypographyProps {
overrides?: { Typography: React.ComponentType };
}
export const StyledTypography: React.FunctionComponent<StyledTypographyProps> = (props) => {
const { children, overrides, ...typographyProps } = props;
const CustomTypography = overrides ?? MainTypography;
return (
<CustomTypography ref={ref} {...typographyProps}>
{children}
</CustomTypography>
)
}
我收到以下错误:JSX element type 'CustomTypography' does not have any construct or call signatures.
任何想法我在这里缺少什么?
解决方案
推荐阅读
- python - 更快地实现像素映射
- c++ - List 上的冒泡排序——在计算上花费了太多时间
- python - 如何在包依赖项> 500MB的AWS lambda上运行python代码?
- android - 如何在 android Studio 上直接向 TFVC 添加解决方案?
- react-native - react-devtools中的“连接到react ....”,当我想连接react native android模拟器时
- javascript - 当 JavaScript 是单线程语言时,如何在 JavaScript 中使用异步非阻塞代码?
- macos - UserNotifications 使用 UNUserNotificationCenter 并在系统偏好设置中设置警报
- swift - SpriteKit - 弹跳节点恒速/速度?
- c# - 如何为从 Unity 中的 Monobehaviour 继承的类编写单元测试?
- python - 如何将可变对象分配给作为 __init__() 函数的参数传递的类成员?