[Suggestion]: Providing formal definition of equality of two JSX values or giving a clarity if there is no formal definition possible.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 11.8k
- Forks
- 7.9k
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 11
Beschreibung
Summary
Formal Definition of Equality of two JSX values. If there is no formal definition possible then give practical guidelines.
Page
https://react.dev/learn/keeping-components-pure
Details
React documentation on "Keeping Components Pure" says that
React assumes that every component you write is a pure function. This means that React components you write must always return the same JSX given the same inputs.
It also mentions:
React offers a “Strict Mode” in which it calls each component’s function twice during development. By calling the component functions twice, Strict Mode helps find components that break these rules.
However, the page does not provide a formal definition of what it means for two JSX values to be "equal."
we can easily say 4 === 4 or "foo" === "foo",
But, To give a simple example, how do we define the equality of two JSX values like: "<Child {childConfig}="object1"> and <Child {childConfig}="object2">"
If object1 and object2 are deeply equal, does that imply that both JSX elements are considered equal as well? Or is equality based on referential identity of object1 and object2?
I think, This distinction is important to understand what it truly means of two JSX values being same.
If such a definition exists elsewhere in the React documentation, it would be helpful to reference it explicitly from this page to clarify expectations around JSX equality and purity.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der im Issue verlinkten Seite „Keeping Components Pure“ und prüfe deren Erklärung zu gleichen Eingaben und JSX-Ergebnissen. Kläre, ob JSX-Gleichheit formal definiert oder durch praktische Hinweise zu Objektidentität und tiefer Gleichheit ersetzt werden sollte, und füge einen ausdrücklichen Verweis oder eine Erklärung hinzu, damit Leser wissen, was „dasselbe JSX“ bedeutet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, react
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100