From 41ced2fffe21424dd0138a77dc13dd0acb4d4963 Mon Sep 17 00:00:00 2001 From: TarsisViana <159029529+TarsisViana@users.noreply.github.com> Date: Fri, 2 Aug 2024 12:08:42 +0100 Subject: [PATCH] Update keys_in_react.md: fix typo in line 82 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. --- react/getting_started_with_react/keys_in_react.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/getting_started_with_react/keys_in_react.md b/react/getting_started_with_react/keys_in_react.md index b4adc29fbaa..1fdf2184f5b 100644 --- a/react/getting_started_with_react/keys_in_react.md +++ b/react/getting_started_with_react/keys_in_react.md @@ -79,7 +79,7 @@ function MonthList() { } ``` -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. +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. ```jsx const todos = [