I am an iOS developer, but I know a little javascript. I am trying to use the AlertIOS, the document api is this
static alert(title: string, message?: string, buttons?: Array<{ text: ?string; onPress: ?Function; }>)
I am confused with the parameters. I tried to write like this,but it give me error. AlertIOS('Username empty', 'Please type your username', buttons: {{text: 'Cancel', onPress: onPressCancel}});
How can i use AlertIOS properly ?
If you look at the documentation, it's says that there's an AlertIOS
API with a static method called alert
. That means you can call it like this:
AlertIOS.alert('Username empty', 'Please type your username', [{text: 'Cancel', onPress: onPressCancel}]);
Notice that you also don't need the "buttons:" prefix for the buttons array - that part of your call wasn't valid syntax anyway.
The method signature for alert is documented using Flow type annotations. Each argument is described like this:
And if the name has a question mark, that argument is optional. So, in this case the arguments are:
You'll also need to make sure you require
the AlertIOS API, probably something like this:
var {
AppRegistry,
StyleSheet,
View,
AlertIOS
} = React;
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With