Skip to content

Commit 5dc11dc

Browse files
committed
fix cannot access 'unobserve' before initialization
1 parent 3041b8b commit 5dc11dc

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)