Receive job offers within weeks with our proven curriculum,
market-leading strategies , and expert support.
Your submissions will be reviewed and optimized by expert mentors.
export function useLoadStylesheet(stylesheets: any, slug: string) {
useEffect(() => {
// Add stylesheets dynamically
const linkElements = stylesheets.map(({ href, id, media = "all" }: any) => {
if (!document.getElementById(id)) {
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = href;
link.id = id;
link.media = media;
document.head.appendChild(link);
return link;
}
return null;
});
return () => {
// Clean up dynamically added stylesheets
linkElements.forEach((link: any) => {
if (link) document.head.removeChild(link);
});
};
}, [stylesheets, slug]);
}