Skip to content

Commit 5da81d2

Browse files
committed
fix: add componentDidMount to InView
Fixes #649
1 parent 34fb96f commit 5da81d2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/InView.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export class InView extends React.Component<
7474
};
7575
}
7676

77+
componentDidMount() {
78+
this.unobserve();
79+
this.observeNode();
80+
}
81+
7782
componentDidUpdate(prevProps: IntersectionObserverProps) {
7883
// If a IntersectionObserver option changed, reinit the observer
7984
if (
@@ -91,7 +96,6 @@ export class InView extends React.Component<
9196

9297
componentWillUnmount() {
9398
this.unobserve();
94-
this.node = null;
9599
}
96100

97101
node: Element | null = null;

0 commit comments

Comments
 (0)