Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues #40 - value not updated on state change #41

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ npm install react-phone-input --save

```jsx
React.render(
<ReactPhoneInput defaultCountry={'us'} onChange{handleOnChange)/>,
<ReactPhoneInput defaultCountry={'us'}
value="+1 514 421 8123"
onChange{handleOnChange)/>,
document.getElementById('content'));
```

If you want to provide a default value, then pass in the optional ``value`` attribute. If the value is updated via a state change in the parent component, then it is reflected in the field. If the phone number is not prefixed by '+', then it will be prefixed by the dialing code of the default country.

Your handler for the ``onChange`` event should expect a string as
parameter, where the value is that of the entered phone number. For example:

Expand All @@ -35,6 +39,8 @@ function handeOnChange(value) {
| excludeCountries | array of country codes to be excluded e.g. ['cu','cw','kz']|
| onlyCountries | array of country codes to be included e.g. ['cu','cw','kz']|
| preferredCountries | array of country codes to be preferred (highlighted at the top) e.g. ['cu','cw','kz']|
| value | initial phone number to be used. numbers without '+' will use default country dialing code |
| onChange | handler for onChange event, which specfies the field value, e.g. ``onChange={(phoneNumber) => { } }`` |

## License

Expand Down
Loading