component.js 745 B

1234567891011121314151617181920
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.styleSingleton = void 0;
  4. var hook_1 = require("./hook");
  5. /**
  6. * create a Component to add styles on demand
  7. * - styles are added when first instance is mounted
  8. * - styles are removed when the last instance is unmounted
  9. * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
  10. */
  11. var styleSingleton = function () {
  12. var useStyle = (0, hook_1.styleHookSingleton)();
  13. var Sheet = function (_a) {
  14. var styles = _a.styles, dynamic = _a.dynamic;
  15. useStyle(styles, dynamic);
  16. return null;
  17. };
  18. return Sheet;
  19. };
  20. exports.styleSingleton = styleSingleton;