Answers for "navigationOptions functional components"

0

navigationOptions functional components

I just tried this, but it doesn't seem to work for me:

const HomeScreen = props => {
    return <Text>Hello World</Text>
}
HomeScreen.navigationOptions = screenProps => ({
    headerTitle: (props) => <Text>Start</Text>,
})

<NavigationContainer>
  <Stack.Navigator>
    <Stack.Screen name="Home" component={HomeScreen} />
  </Stack.Navigator>
</NavigationContainer>
Instead of rendering "Start", it renders "Home". I'm using version 5.10.0

EDIT: Not sure if this is just a hack or not, but it works for me...

<Stack.Screen 
  name="Home"
  component={HomeScreen}
  options={HomeScreen.navigationOptions} />
Posted by: Guest on September-27-2021

Code answers related to "navigationOptions functional components"

Code answers related to "Javascript"

Browse Popular Code Answers by Language