Something went wrong. Try again.
Mirrored from GitHub github.com/roostorg/coop
Something went wrong. Try again.
12345678910111213141516171819202122232425262728import { useEffect, useState } from 'react';
const useDynamicLegacyCSS = (isUsingLegacyCSS: boolean) => { const [cssLoaded, setCssLoaded] = useState(false);
useEffect(() => { setCssLoaded(false);
if (isUsingLegacyCSS) { const link = document.createElement('link'); link.rel = 'stylesheet'; link.href = '/styles/legacyStyles.css'; link.onload = () => setCssLoaded(true); document.head.appendChild(link);
return () => { document.head.removeChild(link); }; } else { setCssLoaded(true); } }, [isUsingLegacyCSS]);
return cssLoaded;};
export default useDynamicLegacyCSS;