react: create-react-class UMD module does not work in AMD environment

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (3 by maintainers)

Commits related to this issue

Most upvoted comments

This should be fixed with create-react-class@15.6.0-rc.0. Please verify (I plan to publish the final 15.6.0 version of it tomorrow).

(function(f) {
  if (typeof exports === "object" && typeof module !== "undefined") {
    module.exports = f(require('react'));
  } else if (typeof define === "function" && define.amd) {
    define(['react'], f);
  } else {
    var g;
    if (typeof window !== "undefined") {
      g = window;
    } else if (typeof global !== "undefined") {
      g = global;
    } else if (typeof self !== "undefined") {
      g = self;
    } else {
      g = this;
    }
    if (typeof g.React === "undefined") {
      throw Error('React module should be required before createClass');
    }
    g.createReactClass = f(g.React);
  }
})(function(React)...

Should do it I think? Haven’t tested. EDIT: Wups, changed React to react.