Skip to content

Commit c2c5fe7

Browse files
authored
Merge pull request magicismight#109 from shynst/master
replaced legacy methods: componentWillMount, componentWillReceiveProps
2 parents c62f46d + 8eb777d commit c2c5fe7

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/ToastContainer.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,19 @@ class ToastContainer extends Component {
108108
};
109109
}
110110

111-
componentWillMount() {
111+
componentDidMount = () => {
112112
Dimensions.addEventListener('change', this._windowChanged);
113113
if (this.props.keyboardAvoiding) {
114114
Keyboard.addListener('keyboardDidChangeFrame', this._keyboardDidChangeFrame);
115115
}
116-
}
117-
118-
componentDidMount = () => {
119116
if (this.state.visible) {
120117
this._showTimeout = setTimeout(() => this._show(), this.props.delay);
121118
}
122119
};
123120

124-
componentWillReceiveProps = nextProps => {
125-
if (nextProps.visible !== this.props.visible) {
126-
if (nextProps.visible) {
121+
componentDidUpdate = prevProps => {
122+
if (this.props.visible !== prevProps.visible) {
123+
if (this.props.visible) {
127124
clearTimeout(this._showTimeout);
128125
clearTimeout(this._hideTimeout);
129126
this._showTimeout = setTimeout(() => this._show(), this.props.delay);
@@ -132,7 +129,7 @@ class ToastContainer extends Component {
132129
}
133130

134131
this.setState({
135-
visible: nextProps.visible
132+
visible: this.props.visible
136133
});
137134
}
138135
};

0 commit comments

Comments
 (0)