Reactjs webapp 仅在 Safari 浏览器中给出错误 - 'undefined' 不是函数(评估 'ReactElementValidator.createElement.bind(null,type)'

Reactjs webapp giving error only in Safari browser - 'undefined' is not a function (evaluating 'ReactElementValidator.createElement.bind(null,type)'

我开发了一个 React SPA,它在除 Safari 之外的所有浏览器上都能正常工作。我在控制台中遇到的错误如下图所示。

错误来自两个文件。一个来自 font-awesome cdn link

其他来自我的 bundle js,它是使用代码

创建的
gulp.task("bundle", function () {
return browserify({
    entries: "./app/js/index.jsx",
    debug: true
}).transform(reactify)
    .bundle()
    .pipe(source("bundle.js"))
    .pipe(gulp.dest("app/"))

})

任何link为什么会出现这个问题?提前致谢。

为绑定添加 polyfill 解决了这个问题。

`if (!Function.prototype.bind) {
   Function.prototype.bind = function(oThis) {
     if (typeof this !== 'function') {
         // closest thing possible to the ECMAScript 5
        // internal IsCallable function
   throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
}

var aArgs   = Array.prototype.slice.call(arguments, 1),
    fToBind = this,
    fNOP    = function() {},
    fBound  = function() {
      return fToBind.apply(this instanceof fNOP
             ? this
             : oThis,
             aArgs.concat(Array.prototype.slice.call(arguments)));
    };

if (this.prototype) {
  // Function.prototype doesn't have a prototype property
  fNOP.prototype = this.prototype; 
}
fBound.prototype = new fNOP();

return fBound;
};
}

`

修复这些问题后,我在使用 REACT INTL 时遇到了另一个错误,它适用于除 safari 之外的所有浏览器。所以在他们的网站上也有一个 polyfill 可用。