未捕获的ReferenceError:未定义require-React-Rails

时间:2019-06-26 23:46:41

标签: ruby-on-rails reactjs react-rails

我正在尝试使用react-rails gem与React和Rails一起工作。到目前为止,我尝试合并第三方库(atlassian的react-beautiful-dnd)毫无困难。现在,我的组件中出现了Uncaught引用错误(请参阅下面的代码)。

从开发工具的控制台窗口提取的组件故障(第10行-var _reactBeautifulDnd = require('react-beautiful-dnd'))

 var _createClass = (function () { function 
   defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var _reactBeautifulDnd = require('react-beautiful-dnd');

var TaskTable = (function (_React$Component) {
  _inherits(TaskTable, _React$Component);

  function TaskTable() {
    _classCallCheck(this, TaskTable);

    _get(Object.getPrototypeOf(TaskTable.prototype), "constructor", this).apply(this, arguments);
  }

  _createClass(TaskTable, [{
    key: "render",
    value: function render() {
      return React.createElement(
        "div",
        null,
        this.props.tasks.map(function (task) {
          return React.createElement(
            _reactBeautifulDnd.Draggable,
            null,
            React.createElement(
              "tr",
              { className: "border pointer" },
              React.createElement(
                "h6",
                { className: "p-4" },
                task.notes
              )
            )
          );
        })
      );
    }
  }]);

  return TaskTable;
})(React.Component);

我已经安装了依赖项,所以我希望所有内容都能正确呈现。

0 个答案:

没有答案