Dashboard sipadu mbip
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.

Manager.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
  2. import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
  3. import _defineProperty from "@babel/runtime/helpers/defineProperty";
  4. import * as React from 'react';
  5. import createContext from 'create-react-context';
  6. export var ManagerReferenceNodeContext = createContext();
  7. export var ManagerReferenceNodeSetterContext = createContext();
  8. var Manager =
  9. /*#__PURE__*/
  10. function (_React$Component) {
  11. _inheritsLoose(Manager, _React$Component);
  12. function Manager() {
  13. var _this;
  14. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  15. args[_key] = arguments[_key];
  16. }
  17. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  18. _defineProperty(_assertThisInitialized(_this), "referenceNode", void 0);
  19. _defineProperty(_assertThisInitialized(_this), "setReferenceNode", function (newReferenceNode) {
  20. if (newReferenceNode && _this.referenceNode !== newReferenceNode) {
  21. _this.referenceNode = newReferenceNode;
  22. _this.forceUpdate();
  23. }
  24. });
  25. return _this;
  26. }
  27. var _proto = Manager.prototype;
  28. _proto.componentWillUnmount = function componentWillUnmount() {
  29. this.referenceNode = null;
  30. };
  31. _proto.render = function render() {
  32. return React.createElement(ManagerReferenceNodeContext.Provider, {
  33. value: this.referenceNode
  34. }, React.createElement(ManagerReferenceNodeSetterContext.Provider, {
  35. value: this.setReferenceNode
  36. }, this.props.children));
  37. };
  38. return Manager;
  39. }(React.Component);
  40. export { Manager as default };