deno.land / x / ruck@v5.0.0 / useCss.mjs

useCss.mjs
// @ts-check
import { createElement as h, useMemo } from "react";
import LinkCss from "./LinkCss.mjs";import useHead from "./useHead.mjs";
/** * React hook to use CSS. * @param {string} href CSS absolute or relative URL. * @param {number} [priority] Priority. */export default function useCss(href, priority) { if (typeof href !== "string") { throw new TypeError("Argument 1 `href` must be a string."); }
if (priority !== undefined && typeof priority !== "number") { throw new TypeError("Argument 2 `priority` must be a number."); }
useHead( // Todo: Unopinionated way to name the key. `2-${href}`, useMemo( () => h(LinkCss, { href }), [href], ), priority, );}
ruck
Ruck is an open source buildless React web application framework for Deno.
GitHub Stars
74
Go to latest

Version Info

Tagged at
a month ago

External Dependencies