You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

unsafeLifecyclesPolyfill.js 1.1 KiB

пре 3 година
12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. var unsafeLifecyclesPolyfill = function unsafeLifecyclesPolyfill(Component) {
  9. var prototype = Component.prototype;
  10. if (!prototype || !prototype.isReactComponent) {
  11. throw new Error('Can only polyfill class components');
  12. } // only handle componentWillReceiveProps
  13. if (typeof prototype.componentWillReceiveProps !== 'function') {
  14. return Component;
  15. } // In React 16.9, React.Profiler was introduced together with UNSAFE_componentWillReceiveProps
  16. // https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#performance-measurements-with-reactprofiler
  17. if (!_react.default.Profiler) {
  18. return Component;
  19. } // Here polyfill get started
  20. prototype.UNSAFE_componentWillReceiveProps = prototype.componentWillReceiveProps;
  21. delete prototype.componentWillReceiveProps;
  22. return Component;
  23. };
  24. var _default = unsafeLifecyclesPolyfill;
  25. exports.default = _default;