Navigate to Specific Function In Screen in React Native

Viewed 180

I am new to react native , And I want to redirect My Drawer Function by navigation. means When navigate to that screen . that drawer function will automatically call.

here is my code of navigation in Browse.js file

  if (json != "error") {
          // if (response && response.length && response[0].message != "error")
          alert(JSON.stringify(json));
          this.props.navigation.navigate("Settings", {
            data: json.title,

and here is my Drawer function in Setting.js file

export default function App() {
  return (
    <NavigationContainer>
      <Drawer.Navigator>
        <Drawer.Screen
          name="User Name"
          options={{
            drawerIcon: ({ focused, size }) => (
              <AntDesign name="user" size={24} color="black" />
            ),
          }}
          component={NotificationsScreen}
        />

Just Tell me what should I write instead of this line

 this.props.navigation.navigate("Settings", {
            data: json.title,
1 Answers

You can use Navigation Event Listener in order to call your function whenever you navigate to this page but be careful don't forget to subscribe after you unmount the component also you can use flag to listen when thuis flag for example is true

Related