React Native only works with 2 clicks

Asked

Viewed 203 times

0

In this code, the function only works after being called twice.

  ubernehmen = () => {
    this.setState({wert: ((this.state.cor*208)+(this.state.letra*8)})
    this.setState({werta: ((this.state.cor2*208)+(this.state.letra2*8)})
    //nas funções abaixo o redux é usado
    this.props.Spur0VarD({...this.state})
    this.props.Spur0VarE({...this.state})
    this.setState({ isModalVisible: false })
    console.log(this.state.werta)
}

//eu chamo a função assim:
<TouchableOpacity onPress={this.ubernehmen}></TouchableOpacity>

1 answer

-1

Maybe your function is taking too long to be processed, or you may have some logic error, try debugging the application to see where the bottleneck is

  • If she’s taking too long to get sued, what could I do? I brought an example of the app, but this occurs several times by the app, but in certain places works normally, sometimes even this code works there.. is totally unpredictable.

  • Try trading the Touchableopacity for a Buttom by importing into the React-Native - import { Buttom } lib from 'React-Native'

  • I switched to Button, and the same behavior happens.. There are other related questions but the resolution is always very targeted, I tried to do with componentwillupdate, even being deprecated, which solved my problem but when I use in Modal it does not allow, and the application is centered in modals.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.