Home > react-nav-router > RouterEvent
RouterEvent type
路由事件,路由跳转时触发
使用 Discriminated Union 表达不同 action 对应的 payload 语义: - navigateTo → payload 为目标 Route - navigateBack → payload 为回退后的新栈长度(见 Router.navigateBack()) - historyPop → 由浏览器 popstate 触发,无 payload
Signature:
typescript
type RouterEvent = {
action: 'navigateTo';
payload: Route;
} | {
action: 'navigateBack';
payload: number;
} | {
action: 'historyPop';
payload: undefined;
};References: Route