Fork me on GitHub
Mitul Shah15:05:16

i’m trying to pass a react component as a prop into another react component but i keep getting this error Objects are not valid as a React child (found: object with keys {$$typeof, render}). If you meant to render a collection of children, use an array instead. Written as such: [:> Button {:icon Question} "Click"] I’m not sure why Question is being passed as an object, any tips?


How are you supposed to use Button in the JS world?

Mitul Shah15:05:36

<Button icon={<Question/>}>
Click me


In this code, <Question/> is not a component but an element. After all, it has <.../> around it.


So you need to use something like (reagent.core/as-element [:> Question]) instead of just Question in your CLJS code. I think (react/createElement Question) should also work.

😄 1
Mitul Shah15:05:47

ah… thank you I tried [:> Question] and (r/as-element Question) but neither of those haha appreciate it!!!!

👍 1