Check out example codes for "swift pop to specific view controller". It will help you in understanding the concepts better.
Code Example 1
let viewControllers: [UIViewController] = self.navigationController!.viewControllers
for aViewController in viewControllers {
if aViewController is YourViewController {
self.navigationController!.popToViewController(aViewController, animated: true)
}
}
Learn ReactJs, React Native from akashmittal.com