Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native Animated node error

Tags:

react-native

I'm with problem in my project.

Animated Node with tag 7 not exists

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

Before rendering this form the app appears the errors from time to time, it is not always that the error appears. I think only when the internet is not very good. But I wanted to be able to handle this error so it did not appear to the user.

My code below.

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);
like image 687
Vitor Lopes de Souza Avatar asked Sep 13 '17 17:09

Vitor Lopes de Souza


2 Answers

I solved this error by turning off native animation drivers for Android. I'm not sure this is the one true answer, but it fixed this particular error for me.

Animated.timing(someAnimation, {
    duration: 5000,
    toValue: 1,
    useNativeDriver: false,
}).start();
like image 95
Nathanael Avatar answered Nov 06 '22 20:11

Nathanael


For Animated Node with tag 7 not exists errors, it is due to useNativeDriver: true in your <Animated/> nodes. Not all animation are supported using nativeDriver as mentioned in the caveats

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

like image 20
Zennichimaro Avatar answered Nov 06 '22 20:11

Zennichimaro