1.1.9 • Published 3 years ago

reactphonenumber2 v1.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-phonenumber2

Telephone number input React component. Made with jquery and select2.

NPM JavaScript Style Guide

Install

npm install --save reactphonenumber2

Usage

First put the following link tag in your html file:

<link
  rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/0.8.2/css/flag-icon.min.css"
/>
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

License

MIT © mehdinajafi

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago