Skip to content

Commit 3a9b707

Browse files
committed
fix(react): Remove deprecation warning with react 16.4
1 parent e4b3c75 commit 3a9b707

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/BareHighlight.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ export default class BareHighlight extends PureComponent<Props, State> {
3636
this.highlightCode();
3737
}
3838

39-
componentWillReceiveProps(nextProps: Props) {
39+
componentDidUpdate(prevProps: Props) {
4040
// If the text changed make sure to reset the state
4141
// This way we ensure that the new text is immediately displayed.
42-
if (nextProps.children !== this.props.children) {
42+
if (prevProps.children !== this.props.children) {
4343
this.setState({ highlightedCode: null, language: null });
44+
return;
4445
}
45-
}
4646

47-
componentDidUpdate() {
4847
// Do not call highlight.js if we already have highlighted code
4948
// If the children changed highlightedCode will be null
5049
if (this.state.highlightedCode) return;

0 commit comments

Comments
 (0)