We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 91b0916 commit 5109efbCopy full SHA for 5109efb
src/use-stylesheet.js
@@ -1,16 +1,18 @@
1
-import { useEffect } from 'react'
+import { useEffect, useState } from 'react'
2
3
const useStyleSheet = href => {
4
+ const [sheet, setSheet] = useState(href)
5
useEffect(() => {
6
const link = document.createElement('link')
7
link.type = 'text/css'
8
link.rel = 'stylesheet'
- link.href = href
9
+ link.href = sheet
10
document.getElementsByTagName('head')[0].appendChild(link)
11
return () => {
12
document.getElementsByTagName('head')[0].removeChild(link)
13
}
- }, [href])
14
+ }, [sheet])
15
+ return [sheet, setSheet]
16
17
18
export { useStyleSheet }
0 commit comments