Home > database >  Accessing Header inside react Component file
Accessing Header inside react Component file

Time:01-12

can someone help with how to access the header from the actual component in react-navigation-6? I am trying to set the title based on some data in the component: example: how can I access this A.js file

A.js
const A = (props)=>{
       return <Text>Hello World</Text>
}
export default A

thanks

CodePudding user response:

You can use navigation.setOptions like below

const A = (props)=> {
  useEffect(() => props.navigation.setOptions({title: 'new title'}), []);
  return <Text>Hello World</Text>
}
export default A

Ref : Updating options with setOptions

  •  Tags:  
  • Related