Skip to content

Commit

Permalink
Update keys_in_react.md: fix typo in line 82
Browse files Browse the repository at this point in the history
The sentence "Using `key={Math.random()}` or `key={uuid()}` *while* rendering the list defeats the purpose of the list, ..." doesn't really make sense and maybe the intended was:

"Using `key={Math.random()}` or `key={uuid()}` *while* rendering the list defeats the purpose of the key, ..."

I checked with some collaborators on discord that seem to agree.
  • Loading branch information
TarsisViana authored and 01zulfi committed Aug 2, 2024
1 parent 3265b6c commit a72eda6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion react/getting_started_with_react/keys_in_react.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function MonthList() {
}
```

<span id="anti-pattern">Keys are straightforward to use, though there is an anti-pattern you should be aware of. Keys should never be generated on the fly. Using `key={Math.random()}` or `key={uuid()}` *while* rendering the list defeats the purpose of the list, as now a new `key` will get created for every render of the list. As shown in the above example, `key` should be inferred from the data itself.</span>
<span id="anti-pattern">Keys are straightforward to use, though there is an anti-pattern you should be aware of. Keys should never be generated on the fly. Using `key={Math.random()}` or `key={uuid()}` *while* rendering the list defeats the purpose of the key, as now a new `key` will get created for every render of the list. As shown in the above example, `key` should be inferred from the data itself.</span>

```jsx
const todos = [
Expand Down

0 comments on commit a72eda6

Please sign in to comment.