Skip to content

Commit 58054ac

Browse files
authored
Merge pull request #44 from allandiego/master
Update deprecated component lifecycle
2 parents 94b8a64 + ff9e4f1 commit 58054ac

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,26 @@ export default class SwitchSelector extends Component {
3636
this.state = {
3737
selected: this.props.initial ? this.props.initial : 0
3838
};
39-
this.animatedValue = new Animated.Value(
40-
this.props.initial
41-
? I18nManager.isRTL
42-
? -(this.props.initial / this.props.options.length)
43-
: this.props.initial / this.props.options.length
44-
: 0
45-
);
46-
}
4739

48-
componentWillMount() {
4940
this._panResponder = PanResponder.create({
5041
onStartShouldSetPanResponder: this.shouldSetResponder,
5142
onMoveShouldSetPanResponder: this.shouldSetResponder,
5243
onPanResponderRelease: this.responderEnd,
5344
onPanResponderTerminate: this.responderEnd
5445
});
46+
47+
this.animatedValue = new Animated.Value(
48+
this.props.initial
49+
? I18nManager.isRTL
50+
? -(this.props.initial / this.props.options.length)
51+
: this.props.initial / this.props.options.length
52+
: 0
53+
);
5554
}
5655

57-
componentWillReceiveProps(nextProps) {
58-
if (nextProps.value !== this.props.value) {
59-
this.toggleItem(nextProps.value, !this.props.disableValueChangeOnPress);
56+
componentDidUpdate(prevProps) {
57+
if (prevProps.value !== this.props.value) {
58+
this.toggleItem(prevProps.value, !this.props.disableValueChangeOnPress);
6059
}
6160
}
6261

0 commit comments

Comments
 (0)