Skip to content

Commit

Permalink
fix(inpage-navigation): warning Can't perform a React state update on…
Browse files Browse the repository at this point in the history
… an unmounted component
  • Loading branch information
ichim-david committed Apr 12, 2024
1 parent c26e092 commit 1192493
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ui/InpageNavigation/InpageNavigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class InpageNavigation extends Component {
scrollPosition: 0,
removeClass: 'hidden',
};
this.debouncedHandleInpageNavigationVisibility = debounce(
this.handleInpageNavigationVisibility,
250,
);
}

handleInpageNavigationVisibility = () => {
Expand All @@ -25,12 +29,16 @@ class InpageNavigation extends Component {
componentDidMount() {
window.addEventListener(
'scroll',
debounce(this.handleInpageNavigationVisibility, 250),
this.debouncedHandleInpageNavigationVisibility,
);
}

componentWillUnmount() {
window.removeEventListener('scroll', this.handleInpageNavigationVisibility);
window.removeEventListener(
'scroll',
this.debouncedHandleInpageNavigationVisibility,
);
this.debouncedHandleInpageNavigationVisibility.cancel();
}

onInpageNavigationClick = () => {
Expand Down

0 comments on commit 1192493

Please sign in to comment.