Skip to content

Commit 43d9356

Browse files
authored
Merge pull request #122 from alexnaiman/fix_for_react_native_update
PR to fix react-native warning on `componentWillReceiveProps`
2 parents 776ea25 + dee6a83 commit 43d9356

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

examples/CustomPicker/ModalPickerImage/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export default class ModalPicker extends BaseComponent {
6262
this.setState({ cancelText: this.props.cancelText });
6363
}
6464

65-
componentWillReceiveProps(nextProps) {
66-
this.setState({ data: nextProps.data });
65+
componentDidUpdate() {
66+
this.setState({ data: this.props.data });
6767
}
6868

6969
onChange(item) {

lib/countryPicker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ export default class CountryPicker extends Component {
3333
this.onValueChange = this.onValueChange.bind(this);
3434
}
3535

36-
componentWillReceiveProps(nextProps) {
36+
componentDidUpdate() {
3737
this.setState({
38-
selectedCountry: nextProps.selectedCountry,
38+
selectedCountry: this.props.selectedCountry,
3939
});
4040
}
4141

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ export default class PhoneInput extends Component {
3838
};
3939
}
4040

41-
componentWillMount() {
41+
componentDidMount() {
4242
if (this.props.value) {
4343
this.updateFlagAndFormatNumber(this.props.value);
4444
}
4545
}
4646

47-
componentWillReceiveProps(nextProps) {
48-
const { value, disabled } = nextProps;
47+
componentDidUpdate() {
48+
const { value, disabled } = this.props;
4949
this.setState({ disabled });
5050

5151
if (value && value !== this.state.value) {

0 commit comments

Comments
 (0)