My purpose is to make a simple Higher Order Component where I have a reusable Section component and where I maybe define some css classes and the <section>
tag:
import React from 'react'
function SectionWrapper(props) {
return <section>{props.children}</section>
}
export default SectionWrapper
Now in my Parent component I can wrap my child-section components like this:
<SectionWrapper>
<SectionTitle />
</SectionWrapper>
<SectionWrapper>
<List />
</SectionWrapper>
Is there a cleaner way to achieve this? E.g. how do I pass the child-component as a prop?
Yes, you could do -
Then use it like
Rename
EnhancedSectionTitle
to whatever makes sense in your app