Fork me on GitHub
#reagent
<
2017-08-18
>
scknkkrer08:08:55

Yeah, sorry.

scknkkrer08:08:08

I am so new on asking questions.

urbank13:08:23

No soda-ash channel so I'm asking here. How do I use the :as prop to render a semantic ui component as a different semantic ui component?

urbank13:08:34

For example [soda-ash.core/Label {:as soda-ash.core/Button}] So this doesn't work because it's a function and not a react component

urbank13:08:54

Oh, sorry. It's right there on the soda-ash github page

urbank13:08:39

Hm.. oh actually it isn't. That's for the :trigger.

gadfly36113:08:55

@urbank I have only ever used :as to define the tag. Say setting it to "div" or "a" or "li" etc.

gadfly36113:08:27

for example

[sa/Label
    {:as "a"
     :href "/foobar"}
    "go to foobar"]

urbank13:08:58

Hm... suppose that and :className should be enough for most cases

jfntn15:08:12

Is it possible to write a higher level component that will walk all of a component’s descendants to do something like say disable input elements?

manutter5116:08:45

I think it’s more common to have the parent set up an atom that the children will read, and then enable/disable themselves depending on the state of the atom.

manutter5116:08:26

Also makes it easier to have an on-click handler that swap!s the atom to a new state, so you can have a child component (eg. a button) that easily updates its siblings.

pesterhazy18:08:45

@jfntn walking the (direct) children is definitely a common pattern in react, though I haven't done it in reagent yet

pesterhazy18:08:04

could you describe your use case a bit more?

jfntn18:08:10

@pesterhazy I have a large form where some of the fields need to be disabled depending on a complex workflow, I know this could be achieved a number of ways but that would be the most generic solution

pesterhazy18:08:13

the reagent way I think would be to use a global state atom for that, or a local one

pesterhazy18:08:34

I think I agree with @manutter51

pesterhazy18:08:58

but the "look at r/children" approach would be interesting as well

pesterhazy18:08:29

If you can make it work, i'd be curious to see what you come up with

jfntn18:08:54

I reverted to the stateful approach for now, but that’s not very reusable unfortunately so I might try to figure it out

jfntn18:08:07

I think it’s non-trivial because it probably requires hook into the reagent render function somehow

noisesmith18:08:35

@jfntn my inclination would be to put the conditionals that need to be calculated into the parent, and have it pass the booleans to the children via the state map