Fix nested NavItems
Currently, a NavItem having more than one child will throw an error. This is due to the `children` property of `NavItem` being passed as the first argument to `React.cloneElement`, which expects a single element. The existing tests are only verifying the case where the `NavItem` has only one child. This commit maps over `children` and calls `React.cloneElement` on each of them.
This commit is contained in:
@@ -100,7 +100,7 @@ class NavItem extends Component {
|
||||
// Automatically expand nested nav if one of the child elements is active
|
||||
const isChildActive = React.Children.toArray(children).some(c => NavItem.isActive(c.props.href, c.props.exact));
|
||||
const isExpanded = expanded || isChildActive;
|
||||
const selfAwareChildren = children && React.cloneElement(children, { child: true });
|
||||
const selfAwareChildren = children && React.Children.map(children, c => React.cloneElement(c, { child: true }));
|
||||
|
||||
let iconElement;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user