Skip to content

Commit

Permalink
fix: add componentDidMount to InView
Browse files Browse the repository at this point in the history
Fixes #649
  • Loading branch information
thebuilder committed Nov 9, 2023
1 parent 34fb96f commit 5da81d2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/InView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export class InView extends React.Component<
};
}

componentDidMount() {
this.unobserve();
this.observeNode();
}

componentDidUpdate(prevProps: IntersectionObserverProps) {
// If a IntersectionObserver option changed, reinit the observer
if (
Expand All @@ -91,7 +96,6 @@ export class InView extends React.Component<

componentWillUnmount() {
this.unobserve();
this.node = null;
}

node: Element | null = null;
Expand Down

0 comments on commit 5da81d2

Please sign in to comment.