0

I'm new in React Native. But i'm aware if this.setState method is run in asynchronous mode.

I have a snippet code like this :

async doSave() {
        await this.props.takeCustomerServiceTicket(this.state.name, this.state.address, this.state.password);
        await this.setState({
            name: '',
            address: '',
            password: ''
        });
    };

What i want to ask are :

  1. Is setState can be await like that? the code not show error, but it really effective to make it await ?

  2. Is my code really synchronous after i use async await like that?

  3. I'm afraid about by reference, are name, address, password that passed via takeCustomerServiceTicket still exist until the function finish ? or it loss because my setState ?

Crocodile
  • 469
  • 2
  • 8
  • 22

0 Answers0