component.js 602 B

12345678910111213141516
  1. import { styleHookSingleton } from './hook';
  2. /**
  3. * create a Component to add styles on demand
  4. * - styles are added when first instance is mounted
  5. * - styles are removed when the last instance is unmounted
  6. * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
  7. */
  8. export var styleSingleton = function () {
  9. var useStyle = styleHookSingleton();
  10. var Sheet = function (_a) {
  11. var styles = _a.styles, dynamic = _a.dynamic;
  12. useStyle(styles, dynamic);
  13. return null;
  14. };
  15. return Sheet;
  16. };