svelte-native icon indicating copy to clipboard operation
svelte-native copied to clipboard

onDestroy not called when navigating

Open daveychu opened this issue 3 years ago • 1 comments

With Svelte we can do some cleanup when a component is destroyed by either returning a function in onMount or using onDestroy. These are both ignored when navigating back via actionBar or using navigate.

Reproduction: https://github.com/daveychu/svelte-native-on-destroy-bug

  • ns run ios
  • Tap "Tap me" to go to "Details"
  • Tap the back button in the action bar or "Tap me" to go back to "Home"
  • Expected: Both intervals cleared
  • Actual: None are cleared

daveychu avatar Sep 16 '22 13:09 daveychu

Page components are usually cached for backwards navigation, and that might be why you face this problem. Upon navigating back using back button or goBack method, component will trigger onDestroy callback.

CatchABus avatar Oct 12 '23 20:10 CatchABus