mirror of
https://github.com/status-im/reagent.git
synced 2025-01-12 21:05:20 +00:00
Use :key in example, and explain why
This commit is contained in:
parent
af45084966
commit
7381678bc2
@ -81,7 +81,7 @@
|
|||||||
(defn lister [props]
|
(defn lister [props]
|
||||||
[:ul
|
[:ul
|
||||||
(for [item (:items props)]
|
(for [item (:items props)]
|
||||||
[:li "Item " item])])
|
[:li {:key item} "Item " item])])
|
||||||
|
|
||||||
(defn lister-user []
|
(defn lister-user []
|
||||||
[:div
|
[:div
|
||||||
@ -174,7 +174,14 @@ Hiccup-like syntax."]
|
|||||||
[:code "seq"] "." ]
|
[:code "seq"] "." ]
|
||||||
|
|
||||||
[demo-component {:comp lister-user
|
[demo-component {:comp lister-user
|
||||||
:defs [:lister :lister-user]}]])
|
:defs [:lister :lister-user]}]
|
||||||
|
|
||||||
|
[:p [:strong "Note: "]
|
||||||
|
"The " [:code "{:key item}"] " part of the " [:code ":li"] " isn't
|
||||||
|
really necessary in this simple example, but passing a unique key
|
||||||
|
for every item in a dynamically generated list of components is
|
||||||
|
good practice, and helps React to improve performance a lot for
|
||||||
|
large lists."]])
|
||||||
|
|
||||||
(defn managing-state []
|
(defn managing-state []
|
||||||
[:div
|
[:div
|
||||||
|
Loading…
x
Reference in New Issue
Block a user