25

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.

I'm not sure it's part of React or if people are using it with 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?

Community
  • 1
  • 1
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
  • Do you need a motivation to use React? – Pavlo Jan 25 '14 at 15:47
  • @Pavlo no I'm already using it and try to understand it better or at least be able to use it correctly. – Sebastien Lorber Jan 25 '14 at 15:48
  • A quick search on github finds no (relevant) references: https://github.com/facebook/react/search?q=requestanimationframe&ref=cmdform There are more references to `setTimeout` and `setInterval`. – Frank van Puffelen Jan 25 '14 at 17:05
  • Pete Hunt talked about `requestAnimationFrame` in an interview in August 2013. The recording and transcript are available: http://javascriptjabber.com/073-jsj-react-with-pete-hunt-and-jordan-walke/ – Ross Allen Jan 25 '14 at 17:52
  • It is used to check for changes in the virtual DOM and update the DOM when necessary. This question isn't really suitable for SO. I would recommend to ask this question on Quora instead. – mekwall Jan 26 '14 at 15:13

1 Answers1

20

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.

Paul O'Shannessy
  • 2,498
  • 17
  • 10