How to disable the “guard” feature in facebook react when working with pure javascript?


I would like to get the native javascript error and not their (react's) "guarded" error.

What is "guard":

As you can see errors like Object [object Object] has no method 'map'. are hard to debug. (

For example I get this error:

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

From this I cannot even know where to start to find what is undefined.

By : Totty.js


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;

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

This video can help you solving your question :)
By: admin