Skip to content

Home > react-nav-router > NavView

Nav 页面组件

包裹页面内容,并根据父级 NavStack 注入的 NavViewContext 中的 appearStatus 变化,在合适的时机触发 willAppear / didAppear / willDisappear / didDisappear 回调。

典型使用:

tsx
<NavView
  willAppear={() => stat('show', 'claw_d_xxx')}
  didDisappear={() => cleanup()}
>
  <PageContent />
</NavView>

实现说明: - 使用 ref 保存"上一次 appearStatus"以推断动画方向;初始值为 null, 这样首次 effect 能识别出"从无到有"的阶段变化(如首帧就是 Normal 的栈顶页面, 会被认定为 entering → visible,并触发 willAppear + didAppear) - 回调通过 ref 读取最新引用,避免依赖 willAppear 等 prop 导致 effect 频繁重跑

Signature:

typescript
NavView: React__default.NamedExoticComponent<NavViewProps>