react-bootstrap: TypeError: can't convert undefined to object Modal.js:22:41

Hi, I am running into a weird problem, and I was curious if it was a known issue. I am trying to use the Modal in V1.00-beta.16, and it is working perfectly in my dev environment. When it is compiled and running on a server, it is getting a TypeError: can't convert undefined to object Modal.js:22:41. I was able to reproduce it on the server with the sample in the docs as well as a minimal <Modal show />. I haven’t been able to reproduce it in a code sandbox yet though.

For what it is worth, I was able to use the ‘Live Demo’ example from the bootstrap docs (https://getbootstrap.com/docs/4.0/components/modal/) and that did work on the server, but I realize that is a different code base anyway. Any ideas on what could be causing this? Is this a known issue? I know this is a vague one, but any help would be appreciated!

  • The server is Ubuntu 18.04.3 LTS
  • The client browsers were Chrome 79 and Firefox 71 on Ubuntu 18.04.3 LTS, I assume it is effecting all other browsers as well.
  • React-Bootstrap V1.00-beta16

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 19 (4 by maintainers)

Most upvoted comments

We managed to fix this bug by removing babel-plugin-transform-react-remove-prop-types from our production babel config.

Looks like this function:

function omitProps(props, propTypes) {
  var keys = Object.keys(props);
  var newProps = {};
  keys.forEach(function (prop) {
    if (!Object.prototype.hasOwnProperty.call(propTypes, prop)) {
      newProps[prop] = props[prop];
    }
  });
  return newProps;
}

was the culprit, as it using propTypes in a nonstandard way, breaking when the production build pipeline mangled propTypes into undefined

Example of the alternative to downgrading that’s described above (removing the babel-plugin-transform-react-remove-prop-types config option):

// babel.config.js

// Remove babel-plugin-transform-react-remove-prop-types to get
// Bootstrap-React@1.0.0-beta.16 working properly
// isProductionEnv && [
//   'babel-plugin-transform-react-remove-prop-types',
//   {
//     removeImport: true
//   }
// ]

Taken from https://stackoverflow.com/questions/60267624/bootstrap-modal-causes-uncaught-typeerror-cannot-convert-undefined-or-null-to