Fork me on GitHub
#reagent
<
2021-12-01
>
Mitul Shah16:12:34

How do I go about passing all props down? Similar to {…restProps}

p-himik16:12:28

You already did that. Props are simply a map - and you can pass it as is.

p-himik16:12:58

If you need to pass additional props, you just assoc or merge something into that map. If you need to pass all the props except some, you just dissoc the unneeded ones.

Mitul Shah16:12:19

I dont think the children are being passed through properly

Mitul Shah17:12:08

fixed it i had children in wrong spots and didnt actually pass it through

👍 2
Mitul Shah21:12:45

[
{:keys [on-click class variant is-full-width disabled?] :as btn-props}
{:keys [left-icon right-icon icon-spacing icon-styles] :as icon-props}
children]
is it possible to do somethign like this

p-himik21:12:32

I have absolutely no clue what you mean. Can you explain it in plain English?

Mitul Shah21:12:35

I want to separate icon and btn props, so that way I can just pass down icon-props rather than all of them

p-himik21:12:55

So you have a button component that has its own props and also has a button inside that should have its own props?

Mitul Shah21:12:53

kinda yeah ideally i just want to pass a few specific props into my btn-content component, not all of them

p-himik21:12:00

You can just combine the two prop maps, assuming the names don't conflict. Or you can make the component more composable by passing just one :label prop - then the user of the button will decide what icon will go where, if anywhere.

Mitul Shah22:12:22

> You can just combine the two prop maps, assuming the names don’t conflict. what does this mean

p-himik22:12:30

Pass all the values in a single map.

Mitul Shah22:12:47

oh so what i did above in the img ^

Mitul Shah22:12:45

In React I’d just declare this and pass it const contentProps = { rightIcon, leftIcon, iconSpacing, children } not sure how to declare in a let