【发布时间】:2021-11-20 15:44:53
【问题描述】:
我想创建一个具有这样类型的 React Native 组件,它接受一个组件并对其应用一些样式:
interface Props {
component: any;
}
const Component: React.FC<Props> = ({component}) => {
const Styled = styled(component)`
background-color: red;
`;
}
我想要的是像这样在 props 中获取组件的 props 类型:
<Component component={Pressable} onPress={() => console.log("sds")} /> //Should accept this props
<Component component={Image} source={{}} /> //Should accept Image props
我怎样才能做到这一点?提前致谢。
【问题讨论】:
标签: typescript react-native styled-components