Ganesh Haran Mogan
Ganesh Haran Mogan

Reputation: 15

Navigation v5 React Native

I have some question on React Native Navigations v5

I have a sub function in my main function. I also have screenOption = (navData) function for customise my navigation and have few header button here which out of my Main function. My Problem now i am not sure how to access the subFunction that located in my mainfunction from my screenOption = (navData). For example whenclick the icon on the header Button and it will trigger the dispatch function to store which located inside the main function.

const mainfunction = (props) =>{

subfunction = async(data) =>{
dispatch(action.delete(data)
}

return ()

}

export const screenOptions = (navData) => {
Item
          title="Delete"
          iconName={
            Platform.OS === "android" ? "md-create" : "ios-trash-outline"
          }
          onPress={() => {
            trigger subfunction here 
          }}
        />
}

Upvotes: 0

Views: 46

Answers (1)

Andresh Singh
Andresh Singh

Reputation: 124

Try creating a custom button and add the component using setOptions

React.useLayoutEffect(() => {
navigation.setOptions({
  headerRight: () => <CustomHeaderButton onPress={customOnPress} />
});
}, []);

Upvotes: 1

Related Questions