Fork me on GitHub
#reagent
<
2022-05-06
>
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?

p-himik15:05:42

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

Mitul Shah15:05:36

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

p-himik15:05:36

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

p-himik15:05:26

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