I have copied a two year old gist from here. It is now working with Figwheel and uses a more recent version of Reagent/React.
I am looking for a generic way of isolating this warning message that comes to the Javascript console: Warning: Every element in a seq should have a unique :key
. The idea is to put a :key
with a generated unique value into all the components. Then the messages ought to disappear and I'll be in a position to see which components needed the unique :key
. My problem is that even although a unique :key
is being put into all of them, the warning message is still seen.
So - would someone be able to tell me which component I have missed or otherwise what I've done wrong? As you can see from the source (permalink) I have added :key (gen-key)
to the two components: [:polyline {:key (gen-key) ...
and [:svg {:key (gen-key) ...
at lines 43 and 68 respectively.
Edit So this is the answer (permalink), in terms of code anyway. Just look for the placement of ^{:key (gen-key)}
at lines 44 and 60.
Note that the function gen-key
was made for debugging. Natural keys to replace.
This is how you might implement gen-key
:
(defn gen-key []
(gensym "key-"))
And here's the way done in the links above:
(def uniqkey (atom 0))
(defn gen-key []
(let [res (swap! uniqkey inc)]
(u/log res)
res))