Check out example codes for "xcode execute code after when navigating back to screen". It will help you in understanding the concepts better.

Code Example 1

// Use this if you don't want to override the navigation style, text, etc.
override func viewWillDisappear(_ animated: Bool) {

    if self.isMovingFromParent {
        // Your code...

Code Example 2

// Use this to override the navigation bar's default back button
	override func viewDidLoad {
        self.navigationItem.hidesBackButton = true
        let newBackButton = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.plain, target: self, action: #selector(YourViewController.back(sender:)))
        self.navigationItem.leftBarButtonItem = newBackButton

    @objc func back(sender: UIBarButtonItem) {
        // Perform your custom actions
        // ...
        // Go back to the previous ViewController
        _ = navigationController?.popViewController(animated: true)

Learn ReactJs, React Native from