How can i access the this.props.navigation.navigate inside the static navigationOptions object?

#1

It works inside the render method but i wanna do it in the Header top right button i.e Add link… kindly guide…

import React, {
Component
} from ‘react’;
import {
View,
Button,
Text
} from ‘react-native’;

// import { FormLabel, FormInput } from ‘react-native-elements’

class AllPropertiesScreen extends React.Component {

static navigationOptions = {
  title: 'All',
  headerRight: <Button title="Add"
  />,
};

render() {
return (

AllPropertiesScreen
AllPropertiesScreen Screen
AllPropertiesScreen Screen

      <Button
              onPress={() => this.props.navigation.navigate('createProperty', {name: 'Lucy'})}
              title="Go to CreateProperty"
        />

  </View>
);

}
}

export default AllPropertiesScreen;

//

#2

Resolved .

static navigationOptions = ({ navigation }) => {
  const {state, setParams} = navigation;
  return {
    title: 'alll',
    headerRight: (
      <Button
        title='Add'
        // onPress={() => setParams({ mode: isInfo ? 'none' : 'info'})}
         onPress={() => navigation.navigate('create')
         }
      />
    ),
  };
};
#3

glad you figured this out!

#4

I appreciate your reply sir.