showing results for - "call function each time visit screen react native functional components"
Hawa
29 Feb 2017
1You have to add focus listener so when you go back, It will refresh the data like
2
3import * as React from 'react';
4import { View } from 'react-native';
5
6function AppScreen({ navigation }) {
7  React.useEffect(() => {
8    const unsubscribe = navigation.addListener('focus', () => {
9      // The screen is focused
10      // Call any action and update data
11    });
12
13    // Return the function to unsubscribe from the event so it gets removed on unmount
14    return unsubscribe;
15  }, [navigation]);
16
17  return <View />;
18}