plumatic/om-tools

Problems with vector conversion(?)

Closed this issue · 4 comments

Had some interesting times with getting owned by some error Maximum call stack size exceeded that points to https://github.com/facebook/react/blob/0.12-stable/src/utils/traverseAllChildren.js#L104

Problem seems to be with om-tools.dom not(?) converting vector to array that makes react go insane when it comes to setting children for dom elements through props. Made a small repo where line 13 fails, but line 12 with the original array and line 14 with manually converting to array works.

https://github.com/whodidthis/testreact/blob/master/src/testreact/core.cljs#L13

Another possibility is the dom elements inside the children vector, whether they are converted from maps to objects.

I would expect this to break as you are seeing it. We do not (currently) have any special handling of props unless they are maps, ie :style. Can I ask why you are explictly passing in :children as prop rather than as arguments after props? As in, (om-tools.dom/div {} (:children props))

Another possibility is the dom elements inside the children vector, whether they are converted from maps to objects.

Not sure what you mean by this; can you clarify?

I think you are correct, I got a bit too carried away in expecting om-tools.dom to convert everything for me. I found this issue while making some components with react and om-tools.dom as the reusability of om components is a bit iffy.

Most of all I'm just glad i found the cause of this issue and am absolutely fine in using (dom/div {:children (clj->js (:children props))}) and (dom/div {} (clj-> js (:children props))) in the future, as I'm the one converting props to clojure in the first place.