简体   繁体   中英

react-navigation: How to wrap navigationOptions in multiple screens

I am just wondering if I have to place navigationOptions in all screens. Something like this:

const AppStackNavigator = createStackNavigator({
  welcome: {
  screen: WelcomeScreen,
  navigationOptions: {
      header: null
    },
  },
  email: {
  screen: EmailLoginScreen,
  navigationOptions: {
      header: null
    },
  },
  password: {
  screen: FindPassWordScreen,
  navigationOptions: {
      header: null
    },
  },
  register: {
  screen: RegisterScreen,
  navigationOptions: {
      header: null
    },
  },
  agree: {
  screen: AgreementScreen,
  navigationOptions: {
      header: null
    }
  }
  })

Can I wrap navigationOptions to all screens? But this will throw me an error.

const AppStackNavigator = createStackNavigator({
  welcome: WelcomeScreen,
  email:EmailLoginScreen,
  password:FindPassWordScreen,
  register: RegisterScreen,
  agree: AgreementScreen,
  navigationOptions: {
      header: null
    },
})

yes it is possible to apply setting to all route, you are just doing it wrong

here,

const AppStackNavigator = createStackNavigator({
  welcome: WelcomeScreen,
  email:EmailLoginScreen,
  password:FindPassWordScreen,
  register: RegisterScreen,
  agree: AgreementScreen,
},{
    navigationOptions: {
      header: null
    }
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM