UNPKG

@orca-fe/tools

Version:
27 lines (26 loc) 669 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = createUseStaticCss; var _ahooks = require("ahooks"); function createUseStaticCss(css) { var count = 0; var styleElement; return function useStaticCss() { (0, _ahooks.useIsomorphicLayoutEffect)(function () { if (count === 0) { styleElement = document.createElement('style'); styleElement.textContent = css; document.head.appendChild(styleElement); } count += 1; return function () { count -= 1; if (count === 0) { document.head.removeChild(styleElement); } }; }); }; }