Skip to content

Commit

Permalink
Merge pull request #22991 from kosmydel/@swm/event-duplication
Browse files Browse the repository at this point in the history
Prevent potential duplication of adding the event listeners
  • Loading branch information
stitesExpensify authored Jul 19, 2023
2 parents 8faf005 + 6465ee7 commit cc51a0d
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/components/DragAndDrop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,11 @@ class DragAndDrop extends React.Component {
}

componentDidUpdate(prevProps) {
if (this.props.isFocused !== prevProps.isFocused) {
if (!this.props.isFocused) {
this.removeEventListeners();
} else {
this.addEventListeners();
}
}

const isDisabled = this.props.disabled;
if (isDisabled === prevProps.disabled) {
if (this.props.isFocused === prevProps.isFocused && isDisabled === prevProps.disabled) {
return;
}
if (isDisabled) {
if (!this.props.isFocused || isDisabled) {
this.removeEventListeners();
} else {
this.addEventListeners();
Expand Down

0 comments on commit cc51a0d

Please sign in to comment.