React native React native/native base:如何在所有屏幕中包含骨架(页眉/页脚)?
在使用本机base的react本机应用程序的所有屏幕中包含页眉/页脚或其他组件的好方法是什么React native React native/native base:如何在所有屏幕中包含骨架(页眉/页脚)?,react-native,native-base,React Native,Native Base,在使用本机base的react本机应用程序的所有屏幕中包含页眉/页脚或其他组件的好方法是什么 主要是为了避免代码重复并使重构更容易。您可以使用组合概念。 制作一个包含页眉、页脚或其他组件的骨架类/函数,并让它在您希望显示内容的部分中呈现this.props.children export class Skeleton { ... render(){ return ( <Container> <Header /> {this.pr
主要是为了避免代码重复并使重构更容易。您可以使用组合概念。 制作一个包含页眉、页脚或其他组件的骨架类/函数,并让它在您希望显示内容的部分中呈现this.props.children
export class Skeleton {
...
render(){
return (
<Container>
<Header />
{this.props.children}
</Container>
);
}
}
然后导入并使用它
class NewScreen {
...
render(){
return (
<Skeleton>
<View>...</View>
</Skeleton>
);
}
}