Skip to content

Commit 75f1c90

Browse files
committed
Pass in app context instead of page context to hoc
1 parent db04ff9 commit 75f1c90

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"npmClient": "yarn",
33
"useWorkspaces": true,
4-
"version": "2.2.2"
4+
"version": "2.2.3"
55
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"publish:release": "lerna publish --tag-version-prefix=\"\" --force-publish=* --no-push --no-git-tag-version",
3535
"start": "yarn build:quick && lerna run start --parallel"
3636
},
37-
"version": "2.2.2",
37+
"version": "2.2.3",
3838
"workspaces": [
3939
"packages/*"
4040
]

packages/next-dark-mode-example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"dependencies": {
77
"next": "^9.3.6",
8-
"next-dark-mode": "^2.2.2",
8+
"next-dark-mode": "^2.2.3",
99
"react": "^16.13.1",
1010
"react-dom": "^16.13.1"
1111
},
@@ -29,5 +29,5 @@
2929
"serve": "next start",
3030
"start": "next"
3131
},
32-
"version": "2.2.2"
32+
"version": "2.2.3"
3333
}

packages/next-dark-mode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@
4343
},
4444
"source": "src/index.tsx",
4545
"types": "es6/index.d.ts",
46-
"version": "2.2.2"
46+
"version": "2.2.3"
4747
}

packages/next-dark-mode/src/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ export default (App: NextComponentType | any, config?: Partial<Config>) => {
100100
return provider ? <DarkModeContext.Provider value={state}>{app}</DarkModeContext.Provider> : app
101101
}
102102

103-
DarkMode.getInitialProps = async ({ Component, ctx }: AppContext) => {
104-
const initialProps = Component.getInitialProps ? await Component.getInitialProps(ctx) : {}
103+
DarkMode.getInitialProps = async (appContext: AppContext) => {
104+
const initialProps = App.getInitialProps ? await App.getInitialProps(appContext) : {}
105105

106106
if (typeof window === 'undefined') {
107-
const cookies = parseCookies(ctx)
107+
const cookies = parseCookies(appContext.ctx)
108108

109109
const autoModeCookie = cookies[autoModeCookieName]
110110
const darkModeCookie = cookies[darkModeCookieName]
@@ -115,8 +115,8 @@ export default (App: NextComponentType | any, config?: Partial<Config>) => {
115115
const autoModeString = autoMode ? '1' : '0'
116116
const darkModeString = darkMode ? '1' : '0'
117117

118-
if (autoModeString !== autoModeCookie) setCookie(ctx, autoModeCookieName, autoModeString, {})
119-
if (darkModeString !== darkModeCookie) setCookie(ctx, darkModeCookieName, darkModeString, {})
118+
if (autoModeString !== autoModeCookie) setCookie(appContext.ctx, autoModeCookieName, autoModeString, {})
119+
if (darkModeString !== darkModeCookie) setCookie(appContext.ctx, darkModeCookieName, darkModeString, {})
120120

121121
return { autoMode, darkMode, initialProps }
122122
}

0 commit comments

Comments
 (0)