mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 01:05: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"
|
||||
}
|
||||
|
||||
if (typeof document === "undefined") return;
|
||||
|
||||
document.documentElement.style.setProperty(
|
||||
"--initial-theme",
|
||||
getInitialTheme()
|
||||
|
||||
@@ -26,9 +26,11 @@ const ThemeProvider: FC<IScopedDownChildren> = ({ children }) => {
|
||||
|
||||
// App's current theme
|
||||
const [theme, setTheme] = useState<ThemeType>(
|
||||
document.documentElement.style.getPropertyValue(
|
||||
"--initial-theme"
|
||||
) as ThemeType
|
||||
typeof document !== "undefined"
|
||||
? (document.documentElement.style.getPropertyValue(
|
||||
"--initial-theme"
|
||||
) as ThemeType)
|
||||
: "dark"
|
||||
)
|
||||
|
||||
const themeObject = useMemo(
|
||||
|
||||
Reference in New Issue
Block a user