How to dynamically change the header title text in a react native app? -


i have been struggling sounds simple. have been trying button when onpressed called. have tried several combinators nothing works. ideas?

export default class jobscreen extends react.component {      constructor(props) {         super(props);     }      static navigationoptions = ({navigation}) => ({         title: "chat with"     });      onpresslearnmore(nav) {          // how update title header           console.log("on pressed" + nav)     }      render() {         const {navigate} = this.props.navigation;           return (             <view style={styles.container}>                 <button                     onpress={() => {this.onpresslearnmore(navigate)}}                     title="learn more"                     color="#841584"                 />              </view>         );     } } 

since navigationoptions has access navigation object, can set param on current screen this.props.navigation.setparam({ title: ‘some title’ }) , access in navigationoptions this

static navigationoptions: ({ navigation }) => {   const { state: { params = {} } } = navigation;   return {     title: params.title || ‘default title’,   }; } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -