Skip to content

Commit

Permalink
Hoist empty styles static constant
Browse files Browse the repository at this point in the history
  • Loading branch information
acusti committed Sep 2, 2024
1 parent bc574aa commit 08f1529
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/styling/src/useStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ type StyleCache = Map<

const styleCache: StyleCache = new Map();

const EMPTY_STYLES_ITEM = { href: '', referenceCount: 0, styles: '' };

export function useStyles(styles: string, initialHref?: string) {
const [stylesItem, setStylesItem] = useState(() => {
if (!styles) return { href: '', referenceCount: 0, styles: '' };
if (!styles) return EMPTY_STYLES_ITEM;

const key = initialHref ?? styles;
let item = styleCache.get(key);
Expand Down

0 comments on commit 08f1529

Please sign in to comment.