source: imaps-frontend/node_modules/react-use/lib/useCss.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.0 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var nano_css_1 = require("nano-css");
5var cssom_1 = require("nano-css/addon/cssom");
6var vcssom_1 = require("nano-css/addon/vcssom");
7var cssToTree_1 = require("nano-css/addon/vcssom/cssToTree");
8var react_1 = require("react");
9var useIsomorphicLayoutEffect_1 = tslib_1.__importDefault(require("./useIsomorphicLayoutEffect"));
10var nano = nano_css_1.create();
11cssom_1.addon(nano);
12vcssom_1.addon(nano);
13var counter = 0;
14var useCss = function (css) {
15 var className = react_1.useMemo(function () { return 'react-use-css-' + (counter++).toString(36); }, []);
16 var sheet = react_1.useMemo(function () { return new nano.VSheet(); }, []);
17 useIsomorphicLayoutEffect_1.default(function () {
18 var tree = {};
19 cssToTree_1.cssToTree(tree, css, '.' + className, '');
20 sheet.diff(tree);
21 return function () {
22 sheet.diff({});
23 };
24 });
25 return className;
26};
27exports.default = useCss;
Note: See TracBrowser for help on using the repository browser.