mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 09:15:58 +02:00
fix: undefined document in ssr
This commit is contained in:
committed by
Jean-Philippe Sirois
parent
b6b295fced
commit
c81d9246c4
@@ -14,6 +14,8 @@ const ThemeScript = () => {
|
|||||||
else return "dark"
|
else return "dark"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof document === "undefined") return;
|
||||||
|
|
||||||
document.documentElement.style.setProperty(
|
document.documentElement.style.setProperty(
|
||||||
"--initial-theme",
|
"--initial-theme",
|
||||||
getInitialTheme()
|
getInitialTheme()
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ const ThemeProvider: FC<IScopedDownChildren> = ({ children }) => {
|
|||||||
|
|
||||||
// App's current theme
|
// App's current theme
|
||||||
const [theme, setTheme] = useState<ThemeType>(
|
const [theme, setTheme] = useState<ThemeType>(
|
||||||
document.documentElement.style.getPropertyValue(
|
typeof document !== "undefined"
|
||||||
|
? (document.documentElement.style.getPropertyValue(
|
||||||
"--initial-theme"
|
"--initial-theme"
|
||||||
) as ThemeType
|
) as ThemeType)
|
||||||
|
: "dark"
|
||||||
)
|
)
|
||||||
|
|
||||||
const themeObject = useMemo(
|
const themeObject = useMemo(
|
||||||
|
|||||||
Reference in New Issue
Block a user