levand / quiescent

A lightweight ClojureScript abstraction over ReactJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

:key property is not passed to react

ul opened this issue · comments

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?

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"}))

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

Thanks!

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

+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?").

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.