I have this layout component as Higher Order Component:
import PropTypes from 'prop-types';
Layout.propTypes = {
children: PropTypes.node.isRequired,
type: PropTypes.string.isRequired
};
function Layout({ children, type }) {
return (
<div>
{children}
{type}
</div>
);
}
export function withLayout(Component) {
Component.Layout = Layout;
return Component;
}
I am using it with another component like this:
import Layout from './
function ChildElement() {
return (
<>
This is the child element
</>
);
}
export default withLayout(ChildElement);
How can I pass the type prop into from withLayout(ChildElement)?
I have tried to pass in the type prop into it by passing a prop to <ChildElement type="Hello" /> but that will only work in <ChildElement /> and not withLayout() How do I make it work?
Thanks in advance.