I have an imported React component that I have no control over and I want to inject? content into it. How can I do that?
Pseudocode:
A component might look like this:
export const Component = ( props ) => {
const { children } = props
return (
<div className="some-component">
<div className="header">
<h2>Component header</h2>
// ideally, there would be something like {props.headerContent} here
// How can I add additional content here ?
</div>
<div className="body">
{children}
</div>
</div>
);
};
Usage
import { SomeComponent } from 'some-components-on-npm';
export const MyComponent = () => {
return (
<SomeComponent
headerContent="Obviously won't work"
>
<div>Body content</div>
</SomeComponent>
);
};
EDIT: If it's any easier, I'd be content with injecting content at the root level of the component. It doesn't need to be nested as the example suggests