Fork me on GitHub
#reagent
<
2017-04-23
>
souenzzo15:04:52

I dont know how to change this from render

souenzzo18:04:13

I'm using (aset this "key" "value")... Not sure but working

lxsameer16:04:10

hey guys, How can I use an other component(function) inside properties of an other component ?

urbank17:04:32

@lxsameer What exactly do you mean?

urbank17:04:09

you mean how you can pass a component function as an argument to a component?

lxsameer17:04:04

@urbank I want to do something like this <componentA link={<componentB/>} />

urbank17:04:26

So you want to have a reference to compB in compA?

lxsameer17:04:54

reference ?

lxsameer17:04:14

just want to pass a component as the attributes of an other component

lxsameer17:04:11

here is a real life example

lxsameer17:04:16

<Card thumbnail='/img/carousel-1.png'
  label='Sample Label'
  heading='Sample Heading'
  description='Sample description providing more details.'
  link={<Anchor href=''
  label='Sample anchor' />} />

urbank17:04:40

Well, if you want Anchor to be a child of Card you can pass it like this [card ...args [anchor ...args]]

lxsameer17:04:53

it's not like a child

urbank17:04:59

if Card wants to do something with the hiccup of Anchor

urbank17:04:17

you can just pass the hiccup as the link arg

urbank17:04:29

[card {:link [anchor {...}]}] I think

lxsameer17:04:03

nope , that's not possible

lxsameer17:04:12

Warning: Failed prop type: Invalid prop link of type array supplied to Card, expected a single ReactElement.

urbank17:04:56

Oh... is Card a React component imported from a javascript lib?

urbank17:04:31

Ah, then I think it's like this:

urbank17:04:47

You need it to use a javascript React component as a reagent component

lxsameer17:04:13

@urbank thanks, It worked, but is :> a new thing in reagent ?

urbank17:04:25

I think it's relatively new, yeah

lxsameer17:04:33

thanks any way 😉

urbank17:04:19

No problem 🙂 kinda surprised it just worked... was sure I screwed something up

lxsameer17:04:59

I just used as-element I already have some wrappers around components which imported from react

gadfly36119:04:27

@lxsameer :> is syntactic sugar for adapt-react-class

lxsameer19:04:14

cool thanks