首页 > 解决方案 > 带有 Typescript 返回类型的样式化组件是任何

问题描述

我有一个组件,例如:

class Foo extends React.Component<SkeletonProps, any> { ... }

当我将它与样式组件一起使用时,例如:

const StyledFoo = styled(Foo)`height: 100px`

StyledFoo 的类型是 any(即没有特定的道具类型),我怎样才能让 StyledFoo 保持SkeletonProps它的道具?

标签: reactjstypescriptstyled-components

解决方案


安装对我有用的3rd版本。hoist-non-react-statics

npm add hoist-non-react-statics@3

推荐阅读