diff --git a/package.json b/package.json index 7df3220d..91fe4b96 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "docs:build": "dumi build", "docs:deploy": "gh-pages -d .doc", "compile": "father build && lessc assets/index.less assets/index.css", - "prepublishOnly": "npm run compile && np --yolo --no-publish", + "prepublishOnly": "npm run compile && np --yolo --no-publish --any-branch", "lint": "eslint src/ --ext .tsx,.ts,.jsx,.js", "test": "father test", "coverage": "father test --coverage", diff --git a/src/SubMenu.tsx b/src/SubMenu.tsx index b44ac2da..92ac0a77 100644 --- a/src/SubMenu.tsx +++ b/src/SubMenu.tsx @@ -454,9 +454,10 @@ export class SubMenu extends React.Component { forceSubMenuRender: props.forceSubMenuRender, triggerSubMenuAction: props.triggerSubMenuAction, builtinPlacements: props.builtinPlacements, - defaultActiveFirst: props.store.getState().defaultActiveFirst[ - getMenuIdFromSubMenuEventKey(props.eventKey) - ], + defaultActiveFirst: + props.store.getState().defaultActiveFirst[ + getMenuIdFromSubMenuEventKey(props.eventKey) + ], multiple: props.multiple, prefixCls: props.rootPrefixCls, id: this.internalMenuId, @@ -528,7 +529,11 @@ export class SubMenu extends React.Component { } return ( - + {({ className, style }) => { const mergedClassName = classNames(sharedClassName, className); diff --git a/src/util.ts b/src/util.ts index 9f1ab844..381612c8 100644 --- a/src/util.ts +++ b/src/util.ts @@ -48,10 +48,9 @@ export function loopMenuItemRecursively( } React.Children.forEach(children, (c: React.ReactElement) => { if (c) { - const construct = c.type as - | typeof MenuItemGroup - | typeof MenuItem - | typeof SubMenu; + const construct = c.type as typeof MenuItemGroup & + typeof MenuItem & + typeof SubMenu; if ( !construct || !( diff --git a/src/utils/isMobile.ts b/src/utils/isMobile.ts index d70203ff..24279de0 100644 --- a/src/utils/isMobile.ts +++ b/src/utils/isMobile.ts @@ -25,7 +25,7 @@ function isMobile(userAgent?: string) { // Facebook mobile app's integrated browser adds a bunch of strings that // match everything. Strip it out if it exists. - let tmp = ua.split('[FBAN'); + let tmp = (ua || '').split('[FBAN'); if (typeof tmp[1] !== 'undefined') { [ua] = tmp; }