1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Using componentDidUpdate rather than deprecated componentWillRecieveProps

https://github.com/laurent22/joplin/pull/2165#discussion_r357441917
This commit is contained in:
Elizabeth Schafer 2019-12-15 10:37:10 -05:00
parent 069444fd02
commit c46c080a06

View File

@ -75,9 +75,15 @@ class HeaderComponent extends React.Component {
if (nextProps.windowCommand) {
this.doCommand(nextProps.windowCommand);
}
}
if (nextProps.zoomFactor !== this.props.zoomFactor || nextProps.size !== this.props.size) {
const mediaQuery = window.matchMedia(`(max-width: ${550 * nextProps.zoomFactor}px)`);
componentDidUpdate(prevProps) {
if (prevProps.notesParentType !== this.props.notesParentType && this.props.notesParentType !== 'Search' && this.state.searchQuery) {
this.resetSearch();
}
if (this.props.zoomFactor !== prevProps.zoomFactor || this.props.size !== prevProps.size) {
const mediaQuery = window.matchMedia(`(max-width: ${550 * this.props.zoomFactor}px)`);
const showButtonLabels = !mediaQuery.matches;
if (this.state.showButtonLabels !== showButtonLabels) {
@ -88,12 +94,6 @@ class HeaderComponent extends React.Component {
}
}
componentDidUpdate(prevProps) {
if (prevProps.notesParentType !== this.props.notesParentType && this.props.notesParentType !== 'Search' && this.state.searchQuery) {
this.resetSearch();
}
}
componentWillUnmount() {
if (this.hideSearchUsageLinkIID_) {
clearTimeout(this.hideSearchUsageLinkIID_);