Skip to content

Commit

Permalink
fix(Menu): string in Group/SubMenu causes error, close #952
Browse files Browse the repository at this point in the history
  • Loading branch information
youluna committed Aug 7, 2019
1 parent 67f0d49 commit 18a7f17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/menu/view/group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export default class Group extends Component {
});

const newChildren = children.map(child => {
// to fix https://github.com/alibaba-fusion/next/issues/952
if (typeof child !== 'function' && typeof child !== 'object') {
return child;
}
const { className } = child.props;
const newChildClassName = cx({
[`${prefix}menu-group-item`]: true,
Expand Down
5 changes: 5 additions & 0 deletions src/menu/view/sub-menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ export default class SubMenu extends Component {
const { mode, root } = this.props;

return Children.map(children, child => {
// to fix https://github.com/alibaba-fusion/next/issues/952
if (typeof child !== 'function' && typeof child !== 'object') {
return child;
}

return cloneElement(child, {
parent: this,
parentMode: mode || root.props.mode,
Expand Down

0 comments on commit 18a7f17

Please sign in to comment.