This is a really simple component that can automatically handle loading Google fonts for you.
You simply pass it a config array and it will load the fonts for you by appending a <link />
tag to the document head. It will update itself if the config changes, and will remove itself on unmount.
Example usage:
const App = () => (
<>
<GoogleFontLoader fonts={[
{
font: 'Roboto',
weights: [400],
},
{
font: 'Roboto Mono',
weights: [400, 700],
},
]} />
<p style={{ fontFamily: 'Roboto Mono, monospaced' }}>This will be in Roboto Mono!</p>
<p style={{ fontFamily: 'Roboto, sans-serif' }}>This will be in Roboto!</p>
</>
);