@jeyserver/react-phonenumber-select
v2.0.0
Published
Telephone number with country selector React component
Downloads
1
Readme
react-phonenumber-select
Telephone number input React component. Made with jquery and select2.
Install
npm i @jeyserver/react-phonenumber-select
Usage
import React, { useState } from 'react'
import { ReactPhonenumber } from 'reactphonenumber2'
const countries = [
{ code: 'IR', name: 'Iran', dialingCode: '98' },
{ code: 'AF', name: 'Afghanistan', dialingCode: '93' },
{ code: 'AL', name: 'Albania', dialingCode: '213' },
{ code: 'AS', name: 'American Samoa', dialingCode: '1684' }
]
const App = () => {
const [phoneNumber, setphoneNumber] = useState<string>('')
const changePhoneNumber = (phoneNumber: string, selected:any) => {
console.log(JSON.stringify({
phoneNumber, selected
}, null, 2))
}
return (
<div>
<ReactPhonenumber
onChange={changePhoneNumber}
countries={countries}
defaultCode="IR"
/>
</div>
)
}
export default App