1 |
|
2 | import App, { AppContext, AppInitialProps } from 'next/app';
|
3 | import React from 'react';
|
4 | import { Store } from 'redux';
|
5 | import { GetServerSideProps, GetServerSidePropsContext, GetStaticProps, GetStaticPropsContext, NextComponentType, NextPageContext } from 'next';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | export declare const HYDRATE = "__NEXT_REDUX_WRAPPER_HYDRATE__";
|
22 | export declare type MakeStore<S extends Store> = (context: Context) => S;
|
23 | export interface InitStoreOptions<S extends Store> {
|
24 | makeStore: MakeStore<S>;
|
25 | context: Context;
|
26 | }
|
27 | export declare const createWrapper: <S extends Store<any, import("redux").AnyAction>>(makeStore: MakeStore<S>, config?: Config<S>) => {
|
28 | getServerSideProps: <P extends {} = any>(callback: GetServerSidePropsCallback<S, P>) => GetServerSideProps<P, import("querystring").ParsedUrlQuery>;
|
29 | getStaticProps: <P_1 extends {} = any>(callback: GetStaticPropsCallback<S, P_1>) => GetStaticProps<P_1, import("querystring").ParsedUrlQuery>;
|
30 | getInitialAppProps: <P_2 extends {} = any>(callback: AppCallback<S, P_2>) => GetInitialAppProps<P_2>;
|
31 | getInitialPageProps: <P_3 extends {} = any>(callback: PageCallback<S, P_3>) => ((context: NextPageContext<any>) => any) | undefined;
|
32 | withRedux: (Component: NextComponentType | App | any) => {
|
33 | new (props: any, context: any): {
|
34 | store: S;
|
35 | hydrate({ initialState, initialProps, ...props }: any, context: any): void;
|
36 | shouldComponentUpdate(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): boolean;
|
37 | render(): JSX.Element;
|
38 | context: any;
|
39 | setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
|
40 | forceUpdate(callback?: (() => void) | undefined): void;
|
41 | readonly props: Readonly<any> & Readonly<{
|
42 | children?: React.ReactNode;
|
43 | }>;
|
44 | state: Readonly<any>;
|
45 | refs: {
|
46 | [key: string]: React.ReactInstance;
|
47 | };
|
48 | componentDidMount?(): void;
|
49 | componentWillUnmount?(): void;
|
50 | componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
51 | getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>): any;
|
52 | componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>, snapshot?: any): void;
|
53 | componentWillMount?(): void;
|
54 | UNSAFE_componentWillMount?(): void;
|
55 | componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
56 | UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
57 | componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
58 | UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
59 | };
|
60 | displayName: string;
|
61 | getInitialProps: any;
|
62 | contextType?: React.Context<any> | undefined;
|
63 | };
|
64 | };
|
65 | declare const _default: <S extends Store<any, import("redux").AnyAction>>(makeStore: MakeStore<S>, config?: Config<S>) => (Component: any) => {
|
66 | new (props: any, context: any): {
|
67 | store: S;
|
68 | hydrate({ initialState, initialProps, ...props }: any, context: any): void;
|
69 | shouldComponentUpdate(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): boolean;
|
70 | render(): JSX.Element;
|
71 | context: any;
|
72 | setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
|
73 | forceUpdate(callback?: (() => void) | undefined): void;
|
74 | readonly props: Readonly<any> & Readonly<{
|
75 | children?: React.ReactNode;
|
76 | }>;
|
77 | state: Readonly<any>;
|
78 | refs: {
|
79 | [key: string]: React.ReactInstance;
|
80 | };
|
81 | componentDidMount?(): void;
|
82 | componentWillUnmount?(): void;
|
83 | componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
84 | getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>): any;
|
85 | componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>, snapshot?: any): void;
|
86 | componentWillMount?(): void;
|
87 | UNSAFE_componentWillMount?(): void;
|
88 | componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
89 | UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
90 | componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
91 | UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
92 | };
|
93 | displayName: string;
|
94 | getInitialProps: any;
|
95 | contextType?: React.Context<any> | undefined;
|
96 | };
|
97 | export default _default;
|
98 | export declare type Context = NextPageContext | AppContext | GetStaticPropsContext | GetServerSidePropsContext;
|
99 | export interface Config<S extends Store> {
|
100 | serializeState?: (state: ReturnType<S['getState']>) => any;
|
101 | deserializeState?: (state: any) => ReturnType<S['getState']>;
|
102 | debug?: boolean;
|
103 | }
|
104 | export interface WrapperProps {
|
105 | initialProps: any;
|
106 | initialState: any;
|
107 | }
|
108 | declare type GetInitialPageProps<P> = NextComponentType<NextPageContext, any, P>['getInitialProps'];
|
109 | declare type GetInitialAppProps<P> = ({ Component, ctx }: AppContext) => Promise<AppInitialProps & {
|
110 | pageProps: P;
|
111 | }>;
|
112 | export declare type GetStaticPropsCallback<S extends Store, P> = (store: S) => GetStaticProps<P>;
|
113 | export declare type GetServerSidePropsCallback<S extends Store, P> = (store: S) => GetServerSideProps<P>;
|
114 | export declare type PageCallback<S extends Store, P> = (store: S) => GetInitialPageProps<P>;
|
115 | export declare type AppCallback<S extends Store, P> = (store: S) => GetInitialAppProps<P>;
|
116 | export declare type Callback<S extends Store, P> = GetStaticPropsCallback<S, P> | GetServerSidePropsCallback<S, P> | PageCallback<S, P> | AppCallback<S, P>;
|
117 | declare module 'next' {
|
118 | interface NextPageContext<S extends Store = any> {
|
119 | |
120 |
|
121 |
|
122 | store: S;
|
123 | }
|
124 | }
|