如何在 React native 中创建全局布局组件?

How to create global layout component in React native?

我在我的项目中使用 React router flux,我需要为我的应用程序提供全局视图 所以我创建了名为 layout 的组件,但这没有回答。 我的代码:

---布局组件

 render() {
        return (
<View style={[styles.container,styles.justify_center,styles.align_items_center]}>

</View>
        );
    }

---登录组件

render() {
        return (
 <layout>
<Text>Test</Text>
</layout>
        );
    }

在组件中使用 this.props.children 以包含调用此组件时包含的所有子项。

只需更新您的布局组件,如下所示:

render() {
  return (
    <View style={[styles.container,styles.justify_center,styles.align_items_center]}>
      {this.props.children}
    </View>
  );
}