Skip to content

Commit

Permalink
Improve error message when a map passed by mistake as a child to frag…
Browse files Browse the repository at this point in the history
…ment

... or to ErrorBoundary (which uses comp/fragment).

Without this change, we assume the map is props, and end up getting a _warning_ like "Warning: Invalid prop `some-prop...` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props."

With this change, we get a proper _error_ about trying to render the wrong type, and in which component.
  • Loading branch information
holyjak committed Oct 27, 2024
1 parent 23a0aca commit b5b9dab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/com/fulcrologic/fulcro/components.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,9 @@
[{} args])]
(vec children))
:cljs
(let [[props children] (if (map? (first args))
(let [[props children] (if (and (map? (first args))
;; fragment only supports key,children
(= ["key"] (->> args first keys (map name))))
[(first args) (rest args)]
[#js {} args])]
(apply react/createElement react/Fragment (clj->js props) (force-children children)))))
Expand Down

0 comments on commit b5b9dab

Please sign in to comment.