svelte-native
svelte-native copied to clipboard
onDestroy not called when navigating
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
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.