I have a custom component with multiple sub components like this:
interface MyComponentProps {
ref: any;
};
function MyComponent(props: MyComponentProps){
return <>
<input id="name" type="number" />
<input id="age" type="text" />
</>
}
I'd like props.ref to contain values of all subcomponents, when accessed from the outside.
Example: myref.current?.value.name and myref.current?.value.age should be possible. How do I do that?
Constraints:
- Why am I searching for a ref-solution?
- I'd like to keep the interface of the component as native-felt as possible.