How to add a text input to alert in react native

Solution 1:

This is possible. I believe this was only available initially for AlertIOS however it seems to have been intergrated to React Native Alert.

Edit: Although its added to Alert it does not seem to work for Android

Use

import { Alert } from 'react-native'; 

onButtonPress = () => {
    Alert.prompt(
      "Enter password",
      "Enter your password to claim your $1.5B in lottery winnings",
      [
        {
          text: "Cancel",
          onPress: () => console.log("Cancel Pressed"),
          style: "cancel"
        },
        {
          text: "OK",
          onPress: password => console.log("OK Pressed, password: " + password)
        }
      ],
      "secure-text"
    );
  };
}

More details: https://reactnative.dev/docs/alertios

Solution 2:

Use react-native-dialog it works across platform and is simple enough.