首页 > 解决方案 > React Native - 模式中未指定“useNativeDriver”

问题描述

我正在构建一个使用库react-native-image-viewer显示可缩放图像的模式。这是我的自定义组件:

       <Modal
            animationType="slide"
            visible={isVisible}
            transparent={true}
        >
            <ImageViewer imageUrls={images} />
        </Modal>

问题是,当我单击图像时,会显示模态并显示可缩放图像,但会显示以下警告消息:

动画:useNativeDriver未指定。这是一个必需选项,必须明确设置为truefalse

我一直在搜索很多,解决方案找到了在哪里包含这样的内容:

animatedValue = new Animated.Value(-300);

componentDidMount() {
    Animated.timing(this.animatedValue,
        {
            toValue: 0,
            duration: 3000,
            useAnimatedDriver: true,
        }).start();
}

并将ImageViewer包含在 Animated.View 组件中,但我已经尝试过了,我仍然有同样的警告。有什么解决办法吗?提前致谢

标签: react-native

解决方案


推荐阅读