You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not clear how to compose children into an array of objects and provide that to the parent, or to use Typescript to hoist props to the parent.
I'm working on a Step Indicator component, seen below.
The parent code for the component is like so:
<StepIndicator
stepIndicatorSize={stepIndicatorSize}
activeStep={2} // set actual active step as a number
labelSize="medium" // set actual label size, "small" | "medium" | "large"
// convert to array of objects, like steps={[{label: 'Step 1'}, {label: 'Step 2'}]}
steps={children}
/>
So I've added comments to help for some props that are unavailable on the parent, but the steps prop is the one I'm really trying to solve.
Below is the subcomponent for the horizontal single steps.
And here is the code we've hooked up to that subcomponent:
So this emits: <>label: Label </> for each step, but we'd like it to emit { label: "Label }...
without the <> React fragment
in curlies
with the value of the label in ""
Is that even possible? So currently, the output for the whole thing is:
<StepIndicator activeStep={2} // set actual active step as a number
labelSize="medium" // set actual label size, "small" | "medium" | "large"
// convert to array of objects, like steps={[{label: 'Step 1'}, {label: 'Step 2'}]}
steps=<>label: Label </><>label: Label </><>label: Label </>/>
But we'd like it to be:
<StepIndicator
activeStep={2} // set actual active step as a number
labelSize="medium" // set actual label size, "small" | "medium" | "large"
steps={[
{ label: "Label" },
{ label: "Label" },
{ label: "Label" },
Is that possible?
Additionally, if we could:
Look into the children and see which on is the Current variant to return the activeStep to the parent
Look at the Label size prop on the first child to return the value to the labelSize prop on the parent
Totally opening to writing this in a more efficient/different way!
The text was updated successfully, but these errors were encountered:
We don't have anything in the API to allow you to dynamically execute code to create some output, so as you explored already the way to do this today would be to return some JSX and allow code connect to map the children.
We're exploring APIs that'll let you do more freeform transformations like this - will keep you posted if we decide to move forward with these.
I'm using 1.2.4.
It's not clear how to compose children into an array of objects and provide that to the parent, or to use Typescript to hoist props to the parent.
I'm working on a Step Indicator component, seen below.
The parent code for the component is like so:
So I've added comments to help for some props that are unavailable on the parent, but the
steps
prop is the one I'm really trying to solve.Below is the subcomponent for the horizontal single steps.
And here is the code we've hooked up to that subcomponent:
So this emits:
<>label: Label </>
for each step, but we'd like it to emit{ label: "Label }
...Is that even possible? So currently, the output for the whole thing is:
But we'd like it to be:
Is that possible?
Additionally, if we could:
Current
variant to return theactiveStep
to the parentLabel size
prop on the first child to return the value to thelabelSize
prop on the parentTotally opening to writing this in a more efficient/different way!
The text was updated successfully, but these errors were encountered: