Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 <View />;
}
source : https://reactnavigation.org/docs/function-after-focusing-screen/
 
PREVIOUS NEXT
Tagged: #react #native #load #function #time #visit #screen
ADD COMMENT
Topic
Name
7+1 =