Skip to content

Commit

Permalink
chore: Revert useStylesheet back to version in master
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 3, 2020
1 parent 0355d26 commit f0b1969
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/hooks/useStylesheet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';

const useStylesheet = (src, { insertBefore } = {}) => {
const useStylesheet = (src) => {
const [loaded, setLoaded] = useState(false);

useEffect(() => {
Expand All @@ -10,15 +10,10 @@ const useStylesheet = (src, { insertBefore } = {}) => {
link.crossOrigin = 'anonymous';
link.onload = () => setLoaded(true);
link.href = src;

if (insertBefore) {
document.head.insertBefore(link, document.getElementById(insertBefore));
} else {
document.body.appendChild(link);
}
document.head.prepend(link);

return () => document.head.removeChild(link);
}, [src, insertBefore]);
}, [src]);

return loaded;
};
Expand Down

0 comments on commit f0b1969

Please sign in to comment.