Parent Get/Set Child Property
Can a parent component somehow set a property or access the property of a child component?
11 Replies
yes, a parent can set a child property by passing it as a prop to the child
what if children are passed in as props to the parent, like in my example?
let me think lol
you can potentially use context
https://docs.solidjs.com/concepts/context
you can also return an object and then parse it in the parent
that's how
Match
works for example: https://github.com/solidjs/solid/blob/main/packages/solid/src/render/flow.ts#L250
it's a bit cursed, but it works!
if you also want to use this component outside of that parentSolid Playground
Quickly discover what the solid compiler will generate from your JSX template
o i kind of misread op actually, you want to get the props of the children and the do something with it. that can be accomplished with the pattern i talked about before
i'll check that out. i wound up doing this in the mean time, which is less idiomatic, but it works.
if it works, it works!
ok i took a look at the playground. makes sense, a factory function.
how does the <Tabs> decleration looks like?
is it something like
I'd be inclined to preemptively change it to:
See:
https://discord.com/channels/722131463138705510/1238643925988937820/1240220490539466832
https://discord.com/channels/722131463138705510/1342563179468816404