vkbansal/react-contextmenu

Uncaught TypeError: Cannot convert undefined or null to object (on production)

Closed this issue · 4 comments

Version

2.11.0

Steps to reproduce

Use this codebase:

  const menuItemClass = { className: styles.reactContextmenuItem, selectedClassName: styles.reactContextmenuItemSelected, dividerClassName: styles.reactContextmenuItemDivider }

  <ContextMenuTrigger key={`cx-${folder.id}`}  id="cx-menu-cc">
     <FolderItem />
  </ContextMenuTrigger>

  <ContextMenu attributes={menuItemClass} id="cx-menu-cc">
     <MenuItem attributes={menuItemClass}>
       Menu 1
     </MenuItem>
  </ContextMenu>

Expected Behavior

Everything is fine on development environment. However, when I compile my packs to production-ready environment (NODE_ENV=production), react-contextmenu gives an error on startup.

Actual Behavior

connectMenu.js:81 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Module.<anonymous> (connectMenu.js:81)
    at n (bootstrap:19)
    at Module.<anonymous> (index.js:6)
    at n (bootstrap:19)
    at bootstrap:83
    at bootstrap:83

connectMenu.js:81:

var ignoredTriggerProps = [].concat(_toConsumableArray(Object.keys(ContextMenuTrigger.propTypes)), ['children']); // expect the id of the menu to be responsible for as outer parameter

Using TypeScript.

Also my console full of errors (in development) when using classes such as dividerClassName with TypeScript. I cannot assign custom attributes due to this.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Did you fix it?

same problem

this is ContextMenuTrigger's props config
image
After packaging,defaultProps is OK, but propTypes can't find

image

same problem

this is ContextMenuTrigger's props config
image
After packaging,defaultProps is OK, but propTypes can't find

image

fixed here:-

#284