[Suggestion]: clarify behaviour of ref callbacks
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript, react
- Ambito
- documentation
Direzione di ricerca
Inizia dalla sezione ref-callback nella pagina react.dev collegata e esamina il caso di test ridotto di StackBlitz per verificare il comportamento descritto. Chiarisci la frase evidenziata in modo che rimanga corretta quando il callback restituisce una funzione di cleanup e assicurati che la formulazione abbia senso senza fare affidamento sulla nota successiva.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The described behaviour for ref callbacks with null as an argument is ambiguous.
Page
https://react.dev/reference/react-dom/components/common#ref-callback
Details
From https://react.dev/reference/react-dom/components/common#ref-callback:
React will also call your ref callback whenever you pass a different ref callback. In the above example, (node) => { ... } is a different function on every render. When your component re-renders, the previous function will be called with null as the argument, and the next function will be called with the DOM node.
If I understand correctly, the emphasised sentenced is not correct when the ref callback returns a clean up function, as is the case in the referenced example. This needs to be clarified.
There is a note later on which helps a bit, but I still think this sentence could be made clearer so it makes sense in isolation.
Reduced test case to confirm this behaviour: https://stackblitz.com/edit/vitejs-vite-2r9rn6m2?file=src%2FApp.tsx&terminal=dev
- Lingua principale
- JavaScript
- Stelle
- 11.8k
- Fork
- 7.9k
- Merge medio
- 16h 6m
- PR unite (30g)
- 7
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di reactjs/react.dev
-
type: documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
-
bug: unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
type: typos
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
bug: unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Tutte le issue di reactjs/react.dev
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy-website#2595 ·