react-native动画节点错误

时间:2017-09-13 17:49:56

标签: react-native

我的项目中存在问题。

Animated Node with tag 7 not exists

type error: expected dynamic type 'double' but had type 'null'

在呈现此表单之前,应用程序会不时出现错误,并不总是出现错误。我想只有当互联网不是很好时。但我希望能够处理此错误,因此用户不会看到它。

我的代码如下。

FormPrincipal.js

import React, { Component } from 'react';
import { View, Text, ScrollView, Alert, BackHandler } from 'react-native';
import RNExitApp from 'react-native-exit-app';
import ScrollableTabView from 'react-native-scrollable-tab-view';
import { Actions } from 'react-native-router-flux';
import axios from 'axios';
import { connect } from 'react-redux';
import { modificaToken, modificaConsultas, modificaScene } from '../actions/AutenticacaoActions';

import FormFaturamento from './FormFaturamento';
import FormListaConsultas from './FormListaConsultas';

class formPrincipal extends Component {

    componentWillMount() {
        BackHandler.addEventListener('hardwareBackPress', this.handleAndroidBack)
    }

    componentWillUnmount() {
        BackHandler.removeEventListener('hardwareBackPress', this.handleAndroidBack)
    }

    handleAndroidBack = () => {

        if(Actions.currentScene === 'formPrincipal') {
            Alert.alert(
                'Sair',
                'Deseja sair do app?',
                [
                    { text: 'NÃO', onPress: () => {} },
                    { text: 'SIM', onPress: () => RNExitApp.exitApp() },
                ]
            );
            return true;   
        }
    }

    render() {
        return(
                <ScrollableTabView>
                    {this.props.consultas.map( item => <FormListaConsultas tabLabel={item.Grupo} key={item.Grupo} item={item}/>)}
                </ScrollableTabView>
        ) 
    }
}

const mapStateToProps = state => (
    {
        token: state.AutenticacaoReducer.token,
        consultas: state.AutenticacaoReducer.consultas,
        scene: state.AutenticacaoReducer.scene,
        listaConsultas: state.AutenticacaoReducer.listaConsultas
    }
)

export default connect(mapStateToProps, {modificaToken, modificaConsultas, modificaScene})(formPrincipal);

2 个答案:

答案 0 :(得分:3)

我通过关闭Android的本机动画驱动程序解决了此错误。我不确定这是否是一个正确的答案,但它为我解决了此特定错误。

Animated.timing(someAnimation, {
    duration: 5000,
    toValue: 1,
    useNativeDriver: false,
}).start();

答案 1 :(得分:2)

对于Animated Node with tag 7 not exists错误,这是由于useNativeDriver: true节点中的<Animated/>引起的。注意事项中提到,使用nativeDriver并不支持所有动画

https://reactnative.dev/docs/animations#caveats