'How can I update multiple animated values with a single gesture handler event callback in React Native using the Animated library?

How can I update multiple animated values with a single gesture handler in React Native? I want to do something like this, but update the scale value as well as another value.

let scale = new Animated.Value(1)
let foo = new Animated.Value(1)

  const onPinchEvent = Animated.event(
    [
      {
        nativeEvent: { scale: scale }
      },

      { 
        nativeEvent: { focalX: foo }
      }
    ],
    {
       listener: (event) => console.log(event.nativeEvent),
       useNativeDriver: true
    }
  )

I get this error:

Invariant Violation: Event has less arguments than mapping



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source