I'm loading a stylesheet from an external CDN in order to style one page in React. The stylesheet link is injected to <head
> using react-helmet
:
<Helmet>
<link rel="stylesheet" href="example.com/site.css" />
</Helmet>
Unfortunately, before the stylesheet loads there's a FOUC visible for a few milliseconds. I'm integrating an outside service so I can't really load the style in any other way.
I've tried using useEffect
hook and render page only when its ready like so:
const [isPageReady, setPageReady] = useState(false);
useEffect(() => {
setPageReady(true);
}, []);
return (
isPageReady && ( // my page );
)
But the FOUC is still there. Is there a way to wait for the stylesheet to load before I display the page?