反应原生 - 当“resetTo"时路线,没有动画 [英] react native - when "resetTo" route, no animation

查看:57
本文介绍了反应原生 - 当“resetTo"时路线,没有动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用导航器组件.
我有飞溅场景,1 秒后正在显示下一个场景.
我需要在启动结束后重置导航堆栈.
当我使用resetTo方法时,场景之间的过渡一致,没有动画.
我该怎么做动画?

I am using the navigator component.
I have splash scene, and after 1 second the next scene is being show.
I need the nav stack to be reset after the splash end.
When i use the resetTo method, the transition between the scenes accord without animation.
How can i do the animation?

推荐答案

对于看到此线程的任何人,请勿使用 setTimeout!这真的很丑陋,绝对不可维护或可扩展.已经为此内置了一些东西.

For anyone seeing this thread DO NOT use setTimeout! This is really ugly and absolutely not maintainable nor scalable. There is already something built in for that.

您可以使用 onDidFocus 并且效果很好!

You can use the onDidFocus and it works perfectly!

http://facebook.github.io/react-native/releases/0.25/docs/navigator.html#ondidfocus

navigatorDidFocusHandler = route => {
  // call immediatelyResetRouteStack here
};

但是这里要小心,重置路由堆栈会触发render.所以一定要正确处理.

But be careful here, resetting the route stack triggers a render. So be sure to handle this correctly.

这篇关于反应原生 - 当“resetTo"时路线,没有动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆