I have a simple components:
const Sidebar = (props) => { ... }
const SidebarLink = (props) => { ... }
To avoid bloat in imports I want to do simple namespacing:
Sidebar.propTypes = propTypes
Sidebar.Link = SidebarLink
export default Sidebar
And use it like:
<Sidebar>
<Sidebar.Link>...</Sidebar.Link>
<Sidebar.Link>...</Sidebar.Link>
<Sidebar.Link>...</Sidebar.Link>
</Sidebar>
Question:
Are there any cons for this approach? Can somethings go wrong? Is it fine as a whole?
Thanks
from Cons of using compound components
No comments:
Post a Comment