Read the original article:Detecting the End of Navigation Pop Animation
Question
When using NavPathStack.pop(), how can I detect when the pop animation has completed?
Short Answer
You can use the onNavBarStateChange() callback to detect when the system navigation animation completes. This works even with the default system transitions, without requiring custom animations. You can find the code example below;
onNavBarStateChange((flag) => {
if (flag) {
console.log('NavBar', 'Navigation Index change, now is show');
} else {
console.log('NavBar', 'Navigation Index change, now is hide');
}
});
Applicable Scenarios
Useful when you need to perform an action right after the navigation transition finishes (e.g., cleaning up state, starting a new process, etc.) and you're using the system-provided default animation in NavPathStack.pop().
Top comments (0)