reactjs / reactjs/react.dev

[Suggestion]: Add some elaboration to the docs for TypeScript DOM events and Pure Functions

Aperta
#6,752 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

type: documentation
Lingua principale
JavaScript
Stelle
11.8k
Fork
7.9k
Merge medio
1g 11h
PR unite (30g)
11

Descrizione

Summary

The Section on DOM events in the page Using TypeScript, mentions extracting functions, this can be elaborated further to include the case where we do get the types i.e. inline methods.

The section on Pure Functions contain a example of Teacups and guests, the global let guests variable should be incremented by 1, but is incremented by 2. Since, React is running in StrictMode for development, this might be confusing for newbies. Found here: https://react.dev/learn/keeping-components-pure#side-effects-unintended-consequences
Edit: The deep dive for this chapter contains the explanation.

Page

https://react.dev/learn/keeping-components-pure

Details

Add another small example where it shows that we do get types when using inline methods, to make it more clear.

Either turn off Strict mode for this example OR explain why we are getting 2, 4, 6 instead of the expected 1, 2, 3 because of React.StrictMode.

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Apri la pagina collegata keeping-components-pure e la sezione Using TypeScript, quindi individua la discussione sugli eventi DOM relativa all’estrazione delle funzioni. Aggiungi un piccolo esempio di metodo inline che mostri che i tipi degli eventi vengono inferiti e conferma che la spiegazione è chiara per chi è alle prime armi.

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

Valutazione

Stack tecnologico
react, typescript
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
1/5
Tempo stimato
Meno di un'ora
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
50/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.