nogabemist
nogabemist

Reputation: 487

React Native Alert function won't triggered

I just want to do simple tutorial to learn. I simply coded authorization to see alert box but I couldn't run. Also, I'm testing it in webview on browser.

Here is my code.

        console.log('pressed');
        console.log(this.state.mail);
        console.log(this.state.password);
        if (this.state.mail == 'test' && this.state.password == 123) {
            console.log("successful");
        }
        else {
            Alert.alert(
                "Alert Title",
                "My Alert Msg",
                [
                  {
                    text: "Cancel",
                    onPress: () => console.log("Cancel Pressed"),
                    style: "cancel"
                  },
                  { text: "OK", onPress: () => console.log("OK Pressed") }
                ]
              );
            console.log("failed");
        }
    }```

If part works correctly. In else part 'failed' log also works correctly but alert won't work. 

Upvotes: 0

Views: 362

Answers (1)

nogabemist
nogabemist

Reputation: 487

As far as I searched, react native alert component won't work on web browser. I tested it with my mobile phone and saw it works.

Upvotes: 1

Related Questions