native的Animated库的流类型

native的Animated库的流类型

本文介绍了react-native的Animated库的流类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 react-native的Animated 库与 Flow 一起使用.不幸的是,我遇到了一堆无法解决的Flow错误(请参见屏幕截图).

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).

在下面的示例中,我在屏幕上渲染一个圆,并希望在使用 Animated.spring 渲染时使其移动.我需要添加其他任何东西来使Flow进行本机工作吗?

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?

流程版本:0.54.0/本机版本:0.48.0

Flow version: 0.54.0 / react-native version: 0.48.0

当前,我只是忽略 .flowconfig 中的Animated:(

Currently, I am just ignoring Animated in .flowconfig :(

; Ignore Animated
.*/react-native/Libraries/Animated/**/.*

推荐答案

我相信您的特定问题已在最新版本的react-native中解决.可能有用的是,您可以使用 AnimatedValueXY 导入两个代码之一来注释位置

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

这篇关于react-native的Animated库的流类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 08:32