<Navbar>
<Navbar.Item><Navbar.Items>
</Navbar>
Here we can easily create a Navbar component. But how to create Navbar child element Navbar.Item in react.
<Navbar>
<Navbar.Item><Navbar.Items>
</Navbar>
Here we can easily create a Navbar component. But how to create Navbar child element Navbar.Item in react.
This is a pattern known as Compound Components.
You can simply assign another React component as a property of the first.
Example:
const NavBar = props => <div>....</div>;
const NavItem = props => <div>....</div>;
NavBar.Item = NavItem;
export default NavBar;
Here's a reference blog by Kent Dodds I found when I had first discovered Compound Components: https://kentcdodds.com/blog/compound-components-with-react-hooks