mirror of
https://github.com/yude-jp/yude.jp
synced 2025-04-15 11:34:52 +09:00
Replace method (getInitialProps -> getServerSideProps)
This commit is contained in:
parent
acd92dc22c
commit
9cc542ecdf
@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
const getInitialTheme = _ => {
|
const getServerSideTheme = _ => {
|
||||||
if (typeof window !== "undefined" && window.localStorage) {
|
if (typeof window !== "undefined" && window.localStorage) {
|
||||||
const storedPrefs = window.localStorage.getItem("color-theme")
|
const storedPrefs = window.localStorage.getItem("color-theme")
|
||||||
if (typeof storedPrefs === "string") {
|
if (typeof storedPrefs === "string") {
|
||||||
@ -22,7 +22,7 @@ const ThemeContext = React.createContext()
|
|||||||
export default ThemeContext
|
export default ThemeContext
|
||||||
|
|
||||||
export const ThemeProvider = ({ initialTheme, children }) => {
|
export const ThemeProvider = ({ initialTheme, children }) => {
|
||||||
const [theme, setTheme] = React.useState(getInitialTheme)
|
const [theme, setTheme] = React.useState(getServerSideTheme)
|
||||||
|
|
||||||
const rawSetTheme = theme => {
|
const rawSetTheme = theme => {
|
||||||
const root = window.document.documentElement
|
const root = window.document.documentElement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user