react native load function each time visit screen 1

react native load function each time visit screen

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 ;
}
source : https://reactnavigation.org/docs/function-after-focusing-screen/

Here is what the above code is Doing:
1. When the screen is focused, the listener will be called.
2. When the screen is unfocused, the listener will be removed.
3. When the screen is focused again, the listener will be added again.

Similar Posts