#StackBounty: #javascript #reactjs Cons of adding static properties to react components

Bounty: 100

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


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.