Home > other >  Add href phone link to a TextInput
Add href phone link to a TextInput

Time:04-19

I currently have the following in a React Native app:

                 <TextInput
                   style={styles.input}
                   placeholder="Phone"
                   value={formState.phone}
                 />

The value in the above is a phone number how can I make it to where this value text input is an href or link a user can click and dial out?

From a few answers I've seen there is "Linking" from expo in a managed workflow. The example given is:

  <Text {...this.props} onPress={this._handlePress}>
    {this.props.children}
  </Text>

How would I be able to use Linking or any other method to achieve this?

CodePudding user response:

You can also use like this

CodePudding user response:

import { Linking } from "react-native";

_handlePress() {
  Linking.openURL(`tel:${phoneNumber}`);
}
  • Related