wrapInitialProps typing
This commit is contained in:
1 parent
0fab398ca6
commit
05e55d2668
1 file changed
+3
-2
+3
-2
@@ -1,4 +1,5 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import { NextPageContext } from 'next'
|
||||||
|
|
||||||
export interface IResponseItems<T> {
|
export interface IResponseItems<T> {
|
||||||
items: T[]
|
items: T[]
|
||||||
@@ -20,8 +21,8 @@ export async function requestGet<T>(url: string, defaultResponse: T): Promise<T>
|
|||||||
*
|
*
|
||||||
* @param {*} fn
|
* @param {*} fn
|
||||||
*/
|
*/
|
||||||
export function wrapInitialProps(fn) {
|
export function wrapInitialProps(fn: (ctx: NextPageContext) => void) {
|
||||||
return async ctx => {
|
return async (ctx: NextPageContext) => {
|
||||||
if (process.env.NODE_ENV === 'production' && process.browser) {
|
if (process.env.NODE_ENV === 'production' && process.browser) {
|
||||||
return window['__NEXT_DATA__'].props.pageProps;
|
return window['__NEXT_DATA__'].props.pageProps;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user