It existed in version 9.0.0 beta34 and was in good use, but it seems to have been removed from canary version. If there is no special reason, it would be good to save it again. Or is there another way to work with similar 'onFrame'?
oh, I found 'onChange'..
Yeah, renamed to onChange because it may be called outside the requestAnimationFrame loop. For example, if you call the set method of a value:
const lastValue = useRef()
const { foo } = useSpring({
foo: flag ? 1 : 0,
onChange: ({ foo }) => {
lastValue.current = foo
}
})
useEffect(() => {
foo.set(2)
assert(lastValue.current == 2)
})
@aleclarson As I noticed, onChange returns a SpingValue and not,say, a primitive.
How we use onChange to achieve the same thing with onFrame so that we can, for example, scroll a viewport?
@phaistonian Sorry, I don't understand. What have you tried so far? Code plz.
@aleclarson Figured this out - thank you.
Somehow - the excellent documentation - got me a bit confused.
Kudos for the work you did, btw - it's sublime, by all means.
Most helpful comment
Yeah, renamed to
onChangebecause it may be called outside therequestAnimationFrameloop. For example, if you call thesetmethod of a value: