levand / quiescent

A lightweight ClojureScript abstraction over ReactJS
Eclipse Public License 1.0
613 stars 46 forks source link

:key property is not passed to react #29

Closed ul closed 9 years ago

ul commented 10 years ago

Inspecting DOM running TodoMVC example shows that :key property of Item component is not used by React. The same behaviour I noticed using quiescent in my project.

Changing here (react-component #js {:value value :statics static-args}) to (react-component #js {:value value :statics static-args :key (:key value)}) and passing :key in component data forces it to be used, but this is not right fix, I guess.

M.b. I'm doing something wrong, and this is not quiescent issue?

neatonk commented 10 years ago

Some way to specify the key prop of a quiescent component would be nice. In the meantime, I've been wrapping my components in a virtual dom component and setting the key prop on the wrapper. This is far from ideal, but it works.

E.g.

(dom/div #js {:key "foo"}
  (MyComponent {:bar "baz"}))
levand commented 10 years ago

It looks like #27 addresses this: I will merge it as soon as I have time to do due diligence on it.

Thanks!

ul commented 10 years ago

Thank you for the great lib! Wish you enough time for all your projects, you are making world better.

kendagriff commented 10 years ago

+1 on this feature.

I also want to express thanks for your library: I've found it much simpler than Om. Having worked with React.js in Javascript, I do think the ideal Clojure library is one that lets the user work w/ React as close to the metal as possible.

Om has gone the opposite direction, which means users will have to juggle two mental paradigms simultaneously ("Is this React? Or is this Om?").

levand commented 9 years ago

This is fixed in master - you can now specify a :keyfn in a component's options map that will calculate a key based off the given value.