A lightweight solution for looping with great performance and control.
Install
yarn add loop-fns
# or
npm install --save loop-fns
Use
import { loopFrames } from 'loop-fns'
const props = loopFrames((props) => {
// your graphics update logic...
// you can also control the loop within the callback
if (props.currentFrame === 10) {
props.stop()
}
}, 30) // limit to 30fps
props.start()