shimohq / react-native-prompt-android

A polyfill library for Alert.prompt on Android platform, working both on Android and iOS platform.
MIT License
129 stars 74 forks source link

Android not work #27

Open wgltony opened 6 years ago

wgltony commented 6 years ago

Can not get input text value.

Noitidart commented 6 years ago

May you share your code it works for me.

edualm commented 6 years ago

Late to the party, but may help someone:

I had this problem, and order apparently counts.

The cancel argument needs to be the first, like this:

[
                { text: 'Cancel' },
                { text: 'OK', onPress: input => {} }
],

The following will not work under Android:

[
                { text: 'OK', onPress: input => {} }
                { text: 'Cancel' },
],

This is probably a bug, though.

Noitidart commented 6 years ago

@wgltony may you please edit the bug title per @edualm's explanation. Maybe title it "Order of options matters on Android".

Noitidart commented 6 years ago

@edualm you are correct order matters - https://github.com/shimohq/react-native-prompt-android/blob/master/index.android.js#L106

I updated the readme to reflect this.

The third argument can be the following:

()=>void | [ButtonPositive] | [ButtonNegative, ButtonPositive] | [ButtonNeutral, ButtonNegative, ButtonPositive],

Where ()=>void is callback on press of "OK".