When using Animated.createAnimatedComponent(ScrollView)
to create an animated ScrollView
it\'s not longer possible to use scrollTo
.
Building on the answer from @jhm - the new, recommended way to create a ref to a component since React 16.3 is to use React.createRef()
as mentioned by @cyqui.
With a normal (note: non-animated) component, we'd simple create a ref to the ScrollView
in the recommended way:
scrollView = React.createRef();
and use static methods as such:
this.scrollView.current.scrollTo({x: number, y: number, animated: true|false})
EDIT: As of RN 0.62 the below is no longer necessary
However, when working with an Animated
component, we're moving into direct manipulation which requires us to get the native node of the component before calling any static methods. Therefore, you'd end up with the following:
scrollView = React.createRef();
this.scrollView.current.getNode().scrollTo({x: number, y: number, animated: true|false})