this should be simple but i think i'm missing something crucial on how Spring works, the documentation is not much of help.
I have a dynamic list, the user can add elements, when that happens i want to use React Spring to animate the scroll to the bottom of the page (identified by currentBottomY
variable)
i have something like this
const mainRef = useRef<HTMLElement | null>(null)
const [y, setY] = useSpring({
from: { y: mainRef?.current?.scrollTop || 0 },
onFrame: props => {
mainRef.current.scrollTop = props.y
},
})
const onAddRow = () => {
setY({ y: currentBottomY })
}
return (
<animated.div ref={mainRef}>
<List />
</animated.div>
)
I'm getting errors saying i cannot define from
and onFrame
in there but in the docs it says otherwise, i really cannot make heads or tails on this, any help?