clojure - Why is the ^ character used in this ClojureScript snippet? -
in clojurescript re-frame todomvc application find following snippet in todomvc.views namespace.
(defn todo-list [visible-todos] [:ul.todo-list (for [todo @visible-todos] ^{:key (:id todo)} [todo-item todo])]) although have read clojure chapter on metadata don't quite understand purpose of:
^{:key in snippet above. please explain.
the :key react needs when have many items, can unique within group. latest version of react not need these keys. if use latest versions of reframe / reagent, try without :key metadata.
this metadata equivalent placing :key within component. example have equivalent to:
[todo-item {:key (:id todo)} todo] using metadata approach convenience, must in cases easier 'first key in props passed component' approach.
here's more explanation.
Comments
Post a Comment