Skip to content

Commit

Permalink
Move removeListener to unregister
Browse files Browse the repository at this point in the history
So that it’s properly called when the DOMNode is removed from the DOM
  • Loading branch information
EtienneLem committed Jan 6, 2024
1 parent cda05ca commit 96eb041
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/emoji-mart/src/components/Picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export default class Picker extends Component {

componentWillUnmount() {
this.unregister()
this.darkMedia?.removeListener(this.darkMediaCallback)
}

async reset(nextState = {}) {
Expand All @@ -128,6 +127,7 @@ export default class Picker extends Component {

unregister() {
document.removeEventListener('click', this.handleClickOutside)
this.darkMedia?.removeListener(this.darkMediaCallback)
this.unobserve()
}

Expand Down

0 comments on commit 96eb041

Please sign in to comment.