reactjs / reactjs/react.dev

[Suggestion]: Improve key attribute explanation

Open
#7,410 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: documentation
Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

Summary

The current docs for the key attribute do not explain in what scenario React actually relies on it

as far as I can tell, this attribute is only relevant for stateful components that rely on their useCallback destructors to be called when the corresponding entry is removed from a list.

Page

https://react.dev/learn/rendering-lists

Details

This comment on reddit may be a good example of a clear explanation of how react actually relies on the key when rendering

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the key attribute section on https://react.dev/learn/rendering-lists, then read the linked Reddit comment for the suggested explanation. Clarify the scenario in which React relies on keys when rendering list entries, and update the page so the explanation is accurate and understandable.

Written by the indexing model from the issue text.

Assessment

Tech stack
react
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.