'Execution flow in react native after navigation.navigate

Need suggestion and advice,

I am using the below 2 lines of code in react native expo component,

this.props.navigation.navigate("App");
 patchUser(this.state.dataSource.userInfo.username, this.state.dataSource.userInfo.firstName,this.state.dataSource.userInfo.lastName, this.state.dataSource.lastLoginTime);

my question:

Will "patchUser()" be called always, since this.props.navigation.navigate("App") has been executed before and it takes to another component ?



Solution 1:[1]

When navigating to "App", the screen with your code snippet above remains mounted, as described here. Therefore, your code should still execute.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 FredAstaire