I have a requirement to construct props dynamically, confused a bit to structure this. See the following example, the children expression component requires parent component title in this case.
function SomeComponent(props){
return <h1>{props.title}</h1>
}
import SomeComponent from 'someForm';
const contents = {
title: 'hello',
form: SomeComponent
}
Another component:
<Another data={contents}>
function Another(props){
return (
<Form title={props.data.title}>
{props.data.form} => title should be passed to this component expression
something like: <props.data.form title={props.data.title}>
Is it possible or how to do this?
</Form>
);
}
What's the best way to achieve this? HOC is a option, but how exactly is the question?