Tengo este componente de diseño como componente de orden superior:
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; }Lo estoy usando con otro componente como este:
import Layout from './ function ChildElement() { return ( <> This is the child element </> ); } export default withLayout(ChildElement); ¿Cómo puedo pasar el accesorio de type desde withLayout(ChildElement) ?
He intentado pasarle el accesorio de tipo pasando un accesorio a <ChildElement type="Hello" /> pero eso solo funcionará en <ChildElement /> y no withLayout() ¿Cómo hago que funcione?
Gracias por adelantado.