Flow types for react-native's Animated library

烈酒焚心 提交于 2021-01-26 19:22:45

问题


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/**/.*


回答1:


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



来源:https://stackoverflow.com/questions/46040202/flow-types-for-react-natives-animated-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!