Skip to content

Commit

Permalink
Only register styles on first use
Browse files Browse the repository at this point in the history
  • Loading branch information
behowell committed Mar 15, 2024
1 parent 86e54eb commit 008faf1
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ export function makeStyles<Slots extends string | number>(
classNameMap[slotName] = className;
}

let registered = false;
const useStyles = () => {
if (!registered) {
registerStyles(styles);
registered = true;
}
return classNameMap;
};

registerStyles(styles);

return useStyles;
}

0 comments on commit 008faf1

Please sign in to comment.