[Suggestion]: Document using Promises passed from RSC to the client without `use()`
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 11.8k
- Fork
- 7.9k
- Merge medio
- 1g 11h
- PR unite (30g)
- 11
Descrizione
Summary
The docs on RSC should mention whether Promises passed from Server Components can be used without use().
Page
https://react.dev/reference/rsc/server-components
Details
Currently, the docs only discuss resolving Promises passed from the server using use(). Sometimes it can be useful to render a component with partial data and update its state once the promise is fulfilled. This appears to work.:
"use client";
export default function Component({ promise }) {
const [data, setData] = useState(null);
useEffect(() => {
let canceled = false;
promise.then((d) => !canceled && setData(d));
return () => canceled = true;
}, [promise])
return (<p>{data}</p>);
}
However I can't find any mentions of this use case. I think that if this is officially supported, there should be an example showing how to do it. And if not, that should be explicitly stated.
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.
Direzione di ricerca
Inizia dalla pagina Server Components all’indirizzo https://react.dev/reference/rsc/server-components e rivedi la discussione attuale sulle Promises passate ai client components. Determina se il caso d’uso mostrato è ufficialmente supportato e documentalo con un esempio oppure dichiara esplicitamente che non è supportato. Il lavoro è completato quando la pagina affronta chiaramente questo caso d’uso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100