首页 文章

使用React-Navigation - React Native在所有屏幕中显示组件

提问于
浏览
1

我希望使用React Navigation在每个屏幕中显示一个类似按钮(或精确反应原生动作按钮)的组件 .

React Navigation是否在Routes内部有任何选项可以实现一次并在任何地方使用?

注意:我不想在每个.js类中导入Component并在渲染中使用它 .

参考 - >在应用程序的每个屏幕中都像这样 . Floating Action Button Reference

1 回答

  • 0

    使用该按钮创建默认屏幕 . 每当您想要使用该按钮时,使用该组件包装所有项目而不是查看 . 例如,“DefaultScreen”是具有默认组件的视图 . 像这样使用它:

    render(){
      <DefaulScreen>
        {AllOtherItems}
      </DefaulScreen>
    }
    

    并在DefaultScreen中呈现所有这样的孩子:

    class DefaultScreen extends Component {
      render(){
        <View>
         {this.props.children}
         {defaultComponentThatYouWantToPutWithCustomStyle}
        </View>
      }
    }
    

相关问题