React是否使用requestAnimationFrame?如果是这样,它是如何使用它的? [英] Does React use requestAnimationFrame? If so, how does it use it?

查看:913
本文介绍了React是否使用requestAnimationFrame?如果是这样,它是如何使用它的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了两个来源,其中有人说React正在使用 requestAnimationFrame
在此关于Om的博客文章,一个基于React的ClojureScript框架。
另请参阅此SO答案的评论

I found 2 sources where it kind of says that React is using requestAnimationFrame On this blog post about Om, a ClojureScript framework on top of React. Also on the comments of this SO answer.

我不确定它是React的一部分,还是人们在React中使用它。

I'm not sure it's part of React or if people are using it with React.

有人可以告诉我如何在React中使用 requestAnimationFrame ?或者它如何与React一起使用以及为什么我会选择将它与React一起使用?

Can someone tell me what how requestAnimationFrame is used in React if it is? Or how it can be used with React and why I would choose to use it with React?

推荐答案

React目前不使用 requestAnimationFrame 进行DOM更新(我们称之为批处理策略)。批处理策略是可以注意的,所以可以使用其他东西。 Om利用这种可能性并使用 requestAnimationFrame 来批量更新DOM。

React doesn't currently use requestAnimationFrame to do DOM updates (as we call it, the "batching strategy"). The batching strategy is injectible though so it's possible to use something else. Om makes use of that possibility and uses requestAnimationFrame to batch DOM updates.

这篇关于React是否使用requestAnimationFrame?如果是这样,它是如何使用它的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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