diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index beb641e1..f277a993 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4514,6 +4514,7 @@ packages: whatwg-encoding@3.1.1: resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} engines: {node: '>=18'} + deprecated: Use @exodus/bytes instead for a more spec-conformant and faster implementation whatwg-mimetype@4.0.0: resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} diff --git a/src/useOnInView.tsx b/src/useOnInView.tsx index 25440f3d..229a6769 100644 --- a/src/useOnInView.tsx +++ b/src/useOnInView.tsx @@ -5,14 +5,12 @@ import type { } from "./index"; import { observe } from "./observe"; -const useSyncEffect = - ( - React as typeof React & { - useInsertionEffect?: typeof React.useEffect; - } - ).useInsertionEffect ?? +const useSyncEffect = (("useInsertionEffect" in React + ? (React as typeof React & { useInsertionEffect: typeof React.useEffect }) + .useInsertionEffect + : undefined) ?? React.useLayoutEffect ?? - React.useEffect; + React.useEffect) as typeof React.useEffect; /** * React Hooks make it easy to monitor when elements come into and leave view. Call