Open luposlip opened 8 years ago
UPDATE:
Just for your info: I've tried to replace my component fns for generating the Table
and the TableRow
's with code from @DaveWM's https://github.com/DaveWM/reagent-material-ui. And it immediately works:
(defn thing-row [thing-data click-handler is-selected]
(let [thing (:thing thing-data)
thing-id (:thing/id thing)]
[TableRow {:selectable true
:selected (is-selected)
:hoverable true
:on-click click-handler}
[TableRowColumn small-cell-styles (:distance thing-data)]
[TableRowColumn (:thing/name thing)]
[TableRowColumn thing-id]]))
(defn things []
(let [the-things (subscribe [:things])
the-thing (subscribe [:thing])]
(fn []
(let [nearby (:some-things @the-things)
others (:other-things @the-things)
all-things (into nearby others)]
[Table
[TableHeader {:displaySelectAll false
:adjustForCheckbox false}
[TableRow
[TableHeaderColumn small-cell-styles "Distance"]
[TableHeaderColumn "Name"]
[TableHeaderColumn "ID"]]]
[TableBody {:displayRowCheckbox true
:deselectOnClickaway false
:showRowHover true}
(for [thing-data all-things]
^{:key (thing-data-id thing-data)}
[thing-row thing-data
#(do (dispatch [:thing thing-data])
(dispatch [:push {:event-data [:location/update (:location thing-data)]}]))
#(= (thing-data-id @the-thing) (thing-data-id thing-data))])]]))))
And yes, I have tried to move the :key
meta data from the inner to the outer component fn also when using your library! ;)
Best, Henrik
ANOTHER UPDATE: Hmm... I removed the @DaveWM library and reverted back to the version of my code using your library.. And now the stack trace disappeared!
But the first issue remains - the onRowSelection
callback still isn't triggered when splitting into 2 component fns. Reopening.
It's possible that material-ui doesn't want to allow table-body
to have direct child other than table-row
. But that's okay. If you need to reuse some piece of code in reagent in such case, you need to call it as a regular function. So instead of [thing-row ...]
you'd use (thing-row ...)
Hi there!
Generally
cljs-react-material-ui 0.2.19
seems pretty solid from my point of view, using it withreagent 0.6.0-rc
.I have a situation where I create a
Table
(based on data from are-frame
subscription
). When I have all the code for creating therui/table
in the same component fn it works without an issue.But when I split the component into a component fn calculating the output for the
table
and an inner component fn for each row a couple of odd things happen:onRowSelection
defined for therui/table
doesn't trigger. I fixed this by using anon-click
handler for eachrui/table-row
insteadmaterial-ui.inc.js:777 Uncaught Invariant Violation: Objects are not valid as a React child
My components are as follows:
The complete stack trace is:
Am i doing something wrong?
Best, Henrik