Answers for "call function each time visit screen react native functional components"

0

call function each time visit screen react native functional components

You have to add focus listener so when you go back, It will refresh the data like

import * as React from 'react';
import { View } from 'react-native';

function AppScreen({ navigation }) {
  React.useEffect(() => {
    const unsubscribe = navigation.addListener('focus', () => {
      // The screen is focused
      // Call any action and update data
    });

    // Return the function to unsubscribe from the event so it gets removed on unmount
    return unsubscribe;
  }, [navigation]);

  return <View />;
}
Posted by: Guest on September-27-2021

Code answers related to "call function each time visit screen react native functional components"

Code answers related to "Javascript"

Browse Popular Code Answers by Language