Skip to content

Commit c61239d

Browse files
author
Thomas Draier
authored
Fix warning on non-required props (#230)
1 parent 39198c5 commit c61239d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/ui-extender/src/actions/menuAction/menuAction.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ const ItemRender = props => {
4040
<MenuItemRenderer {...props}
4141
onClick={event => {
4242
// Call the action and close the menu
43-
onClick(props, event);
44-
event.stopPropagation();
45-
rootMenuContext.dispatch({type: 'close'});
43+
if (onClick) {
44+
onClick(props, event);
45+
event.stopPropagation();
46+
rootMenuContext.dispatch({type: 'close'});
47+
}
4648
}}
4749
onMouseEnter={event => {
4850
if (menuContext) {
4951
// Open submenu (only if it's not opened already)
50-
if (!menuState.isOpen) {
52+
if (menuState && !menuState.isOpen) {
5153
const c = event.currentTarget.getBoundingClientRect();
5254
menuContext.display(null, {
5355
anchorEl: {
@@ -80,8 +82,8 @@ ItemRender.propTypes = {
8082
rootMenuContext: PropTypes.object,
8183
parentMenuContext: PropTypes.object,
8284
menuContext: PropTypes.object,
83-
menuState: PropTypes.object.isRequired,
84-
onClick: PropTypes.func.isRequired,
85+
menuState: PropTypes.object,
86+
onClick: PropTypes.func,
8587
isVisible: PropTypes.bool
8688
};
8789

0 commit comments

Comments
 (0)