reactjs / reactjs/react.dev

[Typo]: Code example mistake in useMemo page

Aperta Adatta ai principianti
#7,252 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Summary

There is a mistake in the ChatRoom example code on the useMemo page, specifically in the 'Preventing an Effect from firing too often' section.

Page

https://react.dev/reference/react/useMemo#preventing-an-effect-from-firing-too-often

Details

There are two mistakes in the ChatRoom example under the 'Preventing an Effect from firing too often' section:

  1. The line const options = createOptions() suddenly appears in the code without context. It seems like this should be removed.
  2. In the comment 'Only changes when createOptions changes', the reference to 'createOptions' should be replaced with 'options object'. This is because options is the actual dependency in the useEffect.

Screenshot of typo:
스크린샷 2024-10-24 오후 7 28 57

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 di riferimento di React useMemo alla sezione “Preventing an Effect from firing too often” ed esamina l’esempio ChatRoom. Conferma la riga createOptions estranea e il commento sulle dipendenze, quindi verifica che l’esempio sia autonomo e che la formulazione descriva accuratamente l’oggetto options.

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

Valutazione

Stack tecnologico
javascript, react
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
65/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.