-5

我想获得本机 javascript 错误,而不是他们的(反应的)“守卫”错误。

什么是“守卫”:https ://github.com/facebook/react/blob/9270d3d56ea3b196acc099409a38e6c07b191e46/src/vendor/stubs/ReactErrorUtils.js

https://github.com/facebook/react/search?q=guard&ref=cmdform

如您所见,错误Object [object Object] has no method 'map'.很难调试。( http://www.andrewgreig.com/637/ )

例如,我收到此错误:

undefined.__closeView: undefined is not a function react.js:7276
guarded react.js:7276
boundMethod react.js:4920

由此我什至不知道从哪里开始找到未定义的内容。

4

1 回答 1

0

As you gave the guard implementation:

var ReactErrorUtils = {
  /**
   * Creates a guarded version of a function. This is supposed to make debugging
   * of event handlers easier. This implementation provides only basic error
   * logging and re-throws the error.
   *
   * @param {function} func Function to be executed
   * @param {string} name The name of the guard
   * @return {function}
   */
  guard: function(func, name) {
    if (__DEV__) {
      return function guarded() {
        try {
          return func.apply(this, arguments);
        } catch(ex) {
          console.error(name + ': ' + ex.message);
          throw ex;
        }
      };
    } else {
      return func;
    }
  }
};

https://github.com/facebook/react/blob/9270d3d56ea3b196acc099409a38e6c07b191e46/src/vendor/stubs/ReactErrorUtils.js

Maybe you can try to not be in __DEV__ mode, or open an issue to support an easy way to disable it.

于 2014-01-27T14:19:32.960 回答