Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = cloneWithRef;
  6. var _invariant = require('invariant');
  7. var _invariant2 = _interopRequireDefault(_invariant);
  8. var _react = require('react');
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. function cloneWithRef(element, newRef) {
  11. var previousRef = element.ref;
  12. (0, _invariant2.default)(typeof previousRef !== 'string', 'Cannot connect React DnD to an element with an existing string ref. ' + 'Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. ' + 'Read more: https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute');
  13. if (!previousRef) {
  14. // When there is no ref on the element, use the new ref directly
  15. return (0, _react.cloneElement)(element, {
  16. ref: newRef
  17. });
  18. }
  19. return (0, _react.cloneElement)(element, {
  20. ref: function ref(node) {
  21. newRef(node);
  22. if (previousRef) {
  23. previousRef(node);
  24. }
  25. }
  26. });
  27. }