I\'m I understanding it correctly ? Does this two set of code meant the same thing ?Does it have any difference in performance or reliability ?
it's not the same. Animated.event
is used to map gestures like scrolling, panning or other events directly to Animated values. so in your first example this.state.scrollY
is an Animated.Value
. you would probably have code somewhere that initialized it, maybe your constructor would looks something like this:
constructor(props) {
super(props);
this.state = {
scrollY: new Animated.Value(0)
};
}
in your second example this.state.scrollY
is the y value (just the number) that was triggered in the scroll event, but completely unrelated to animation. so you couldn't use that value as you could use Animated.Value
in animation.
it's explained here in the documentation