Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

useIntersection warning with React 19

Aperta
#2,612 5 commenti 28 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
nextjs, react, typescript
Ambito
frontend

Direzione di ricerca

Start with docs/useIntersection.md and follow the useIntersection signature used by its example. Update the accepted ref type so the documented React 19 example type-checks without a warning, then verify the example and related package checks pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
TypeScript
Stelle
44k
Fork
3.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di streamich/react-use

Tutte le issue di streamich/react-use

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.