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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -