#2612·react-use

useIntersection warning with React 19

Author: clacladevCreated Dec 13, 2024Updated Feb 18, 2026

What is the current behavior? Migrating to Nextjs 15.1 and React 19, the useIntersection started to throw a ts warning.

The code in the docs does not work anymore.

const intersectionRef = React.useRef(null);
const intersection = useIntersection(intersectionRef, { ... }); <<< intersectionRef

The error is:

Argument of type 'RefObject<null>' is not assignable to parameter of type 'RefObject<HTMLElement>'.
  Type 'null' is not assignable to type 'HTMLElement'.ts(2345)

useIntersection signature should accept RefObject<HTMLElement | null>.

What is the expected behavior? To not throw a warning. It actually keeps working.

A little about versions:

  • OS: macOS 15.1.1
  • Browser (vendor and version): Chrome 131
  • React: 19
  • react-use: 17.5.1
  • Did this worked in the previous package version? No