【发布时间】:2021-09-12 10:05:37
【问题描述】:
在打字稿界面中,我们可以定义,如:
export interface ViewContainerProps {
style?: ViewStyle | ViewStyle[];
children?: React.ReactNode
aString:string
aNumber:number
}
我想写一个自定义的顶级<View>,覆盖所有屏幕,它看起来像这样:
const VIEW_CONTAINER: ViewStyle = {
width: windowWidth,
height: windowHeight,
};
export interface ViewContainerProps {
style?: ViewStyle | ViewStyle[];
children?: React.ReactNode ///no , something wrong
}
export const ViewContainer = (props: ViewContainerProps) => {
const {style, children} = props;
return <View style={[style, VIEW_CONTAINER]}>{children}</View>;
};
我想让孩子们返回React component 进行交互并执行 React 组件所做的任何事情,我可以在 typescript 界面中放入什么类型的 React?我读了一些文档,说 React.reactNode a light, stateless, immutable, virtual representation of a DOM node,感觉这不是我在创建包装所有子组件的顶级组件时想要的
请帮忙,非常感谢
【问题讨论】:
标签: reactjs typescript react-native