Passing Component in props
I try to generalize the following fragment:
where my component would apply the same ID for the
<label>
and the <input>
but also the <input>
would come as a parameter in props.
Something like this - except that it does not work 😄
And call it like:
Thanks.3 Replies
Why not drop the fieldprop and instead add make FieldLabelProps extend ComponenProps<"input">
You then can use splitProps to extract the label and and just pass the props to an input element
You are right but what if I want to allow
<textarea>
as well? (Although I know the above example is <input>
-specific.)
I go with your recommendation, I'm too beginner for a more generic solution 🙂
Thanks,If you want to make it more generic you may use the Dynamic component and then make two types one where the component prop of dynamic is „input“ and one „textarea“