Skip to content

Commit 3c2f4a1

Browse files
authored
Merge pull request #587 from kik4/fix/cannot_access_unobserve_before_initialization
2 parents 3041b8b + 5dc11dc commit 3c2f4a1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/useInView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export function useInView({
6161
// Ensure we have node ref, and that we shouldn't skip observing
6262
if (skip || !ref) return;
6363

64-
let unobserve: (() => void) | undefined = observe(
64+
let unobserve: (() => void) | undefined;
65+
unobserve = observe(
6566
ref,
6667
(inView, entry) => {
6768
setState({

0 commit comments

Comments
 (0)