在React Native中动画期间更新状态吗? [英] Update state during animation in react native?

查看:55
本文介绍了在React Native中动画期间更新状态吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个组件中有几个活动动画.当我尝试在这些动画期间更新组件状态时,由于重新渲染过程,它们将停止.有什么办法可以防止这种情况的发生?

I have several active animations in a component. When I am trying to update a component state during these animations they stop due to the rerendering process. Is there any way to prevent this from happening?

我使用的动画类似于反应本机文档中的示例,但持续时间更长.

I am using an Animation similar to the example in the react native documentation but with a longer duration.

谢谢!

推荐答案

我知道回答的时间有点晚,但以防万一您或其他人仍然需要它.您可以考虑使用 useNativeDriver:true .您可以在此处查看解释.我基本上可以让您绕过大多数情况下由回调引起的那种阻止操作.

I know that its a little late for answering but just in case you or someone else still needs it. You can consider using useNativeDriver: true. You can check the explanation here. I basically lets you bypass that kind of blocking actions caused by callbacks in most cases.

这篇关于在React Native中动画期间更新状态吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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