I am trying to use react-native's Animated library alongside Flow. Unfortunately, I get a bunch of Flow errors that I cannot resolve (see Screenshot).
In the example below I render a circle on the screen and want to make it move when it is being rendered using Animated.spring
. Is there anything else I need to add to make react-native work with Flow?
Flow version: 0.54.0 / react-native version: 0.48.0
Currently, I am just ignoring Animated in .flowconfig
:(
; Ignore Animated
.*/react-native/Libraries/Animated/**/.*
Flow. Flow is a static type checker for your JavaScript code. It is developed at Facebook and is often used with React. It lets you annotate the variables, functions, and React components with a special type syntax, and catch mistakes early. You can read an introduction to Flow to learn its basics.
I believe your specific problem is fixed in a more recent version of react-native. What might be useful to know is that you can annotate position
with AnimatedValueXY
importing one of the two
import type AnimatedValueXY from 'react-native/Libraries/Animated/src/nodes/AnimatedValueXY';
import type AnimatedValue from 'react-native/Libraries/Animated/src/nodes/AnimatedValue';
It's kinda ugly but I didn't find a better alternative
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With