Simple and lightweight React component for phone numbers with phone code.
Demo here: https://diazweb.github.io/react-phone-simple/
Install the package:
npm i react-phone-simple
Import the component:
import ReactPhoneSimple from "react-phone-simple";
Insert the component in your code:
<ReactPhoneSimple
handleChange={phone => this.props.setPhone(phone)}
defaultPhoneCode={"us"}
/>
props | required | description |
---|---|---|
handleChange | yes | Function to get the returned phone and phoneCode |
defaultPhoneCode | yes | For example: US, ES, DE ... |
defaultPhone | no | If you want to set an existing phone |
placeholder | no | Placeholder of the input |
required | no | Set required attribute |