Skip to content

Commit fac0b42

Browse files
juliopradaJúlio Prada
and
Júlio Prada
authored
add onMount prop (bl00mber#410)
Co-authored-by: Júlio Prada <[email protected]>
1 parent b736f91 commit fac0b42

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

index.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ declare module "react-phone-input-2" {
4949
countries: object[],
5050
hiddenAreaCodes: object[],
5151
) => boolean | string) | boolean;
52+
onMount?(
53+
value: string,
54+
data: CountryData | {},
55+
formattedValue: string
56+
): void;
5257
}
5358

5459
export interface PhoneInputProps extends PhoneInputEventsProps, Style {

src/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class PhoneInput extends React.Component {
9191
onClick: PropTypes.func,
9292
onKeyDown: PropTypes.func,
9393
onEnterKeyPress: PropTypes.func,
94+
onMount: PropTypes.func,
9495
isValid: PropTypes.oneOfType([
9596
PropTypes.bool,
9697
PropTypes.func,
@@ -232,6 +233,9 @@ class PhoneInput extends React.Component {
232233
if (document.addEventListener && this.props.enableClickOutside) {
233234
document.addEventListener('mousedown', this.handleClickOutside);
234235
}
236+
if(this.props.onMount){
237+
this.props.onMount(this.state.formattedNumber.replace(/[^0-9]+/g,''), this.getCountryData(), this.state.formattedNumber)
238+
}
235239
}
236240

237241
componentWillUnmount() {

0 commit comments

Comments
 (0)