Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
use safe lifecycle methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-André Rivet committed Mar 6, 2020
1 parent d87497b commit 76a9465
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/dash-table/components/ControlledTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
}

componentDidMount() {
// Fallback method for paste handling in Chrome
// when no input element has focused inside the table
window.addEventListener('resize', this.forceHandleResize);
document.addEventListener('mousedown', this.handleClick);
document.addEventListener('paste', this.handlePaste);

const {
active_cell,
selected_cells,
Expand All @@ -132,25 +138,14 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
this.handleResize();
}

UNSAFE_componentWillMount() {
// Fallback method for paste handling in Chrome
// when no input element has focused inside the table
window.addEventListener('resize', this.forceHandleResize);
document.addEventListener('mousedown', this.handleClick);
document.addEventListener('paste', this.handlePaste);
}

componentWillUnmount() {
window.removeEventListener('resize', this.forceHandleResize);
document.removeEventListener('mousedown', this.handleClick);
document.removeEventListener('paste', this.handlePaste);
}

UNSAFE_componentWillUpdate() {
this.updateStylesheet();
}

componentDidUpdate() {
this.updateStylesheet();
this.applyStyle();
this.handleResize();
this.handleDropdown();
Expand Down

0 comments on commit 76a9465

Please sign in to comment.