next-redux-wrapper

  • Version 7.0.5
  • Published
  • 70.1 kB
  • No dependencies
  • MIT license

Install

npm i next-redux-wrapper
yarn add next-redux-wrapper
pnpm add next-redux-wrapper

Overview

Redux wrapper for Next.js

Index

Variables

variable HYDRATE

const HYDRATE: string;
  • Quick note on Next.js return types:

    Page.getInitialProps https://nextjs.org/docs/api-reference/data-fetching/getInitialProps as-is

    App.getInitialProps: AppInitialProps https://nextjs.org/docs/advanced-features/custom-app {pageProps: any}

    getStaticProps https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation {props: any}

    getServerSideProps https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering {props: any}

Functions

function _default

_default: <S extends any>(
makeStore: MakeStore<S>,
config?: Config<S>
) => (
Component: any
) => {
new (props: any, context: any): {
store: S;
hydrate({ initialState, initialProps, ...props }: any, context: any): void;
shouldComponentUpdate(
nextProps: Readonly<any>,
nextState: Readonly<any>,
nextContext: any
): boolean;
render(): any;
context: any;
setState<K extends string | number | symbol>(
state: any,
callback?: (() => void) | undefined
): void;
forceUpdate(callback?: (() => void) | undefined): void;
readonly props: Readonly<any> & Readonly<{ children?: React.ReactNode }>;
state: Readonly<any>;
refs: { [key: string]: any };
componentDidMount?(): void;
componentWillUnmount?(): void;
componentDidCatch?(error: Error, errorInfo: any): void;
getSnapshotBeforeUpdate?(
prevProps: Readonly<any>,
prevState: Readonly<any>
): any;
componentDidUpdate?(
prevProps: Readonly<any>,
prevState: Readonly<any>,
snapshot?: any
): void;
componentWillMount?(): void;
UNSAFE_componentWillMount?(): void;
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
UNSAFE_componentWillReceiveProps?(
nextProps: Readonly<any>,
nextContext: any
): void;
componentWillUpdate?(
nextProps: Readonly<any>,
nextState: Readonly<any>,
nextContext: any
): void;
UNSAFE_componentWillUpdate?(
nextProps: Readonly<any>,
nextState: Readonly<any>,
nextContext: any
): void;
};
displayName: string;
getInitialProps: any;
contextType?: React.Context<any> | undefined;
};

    function createWrapper

    createWrapper: <S extends any>(
    makeStore: MakeStore<S>,
    config?: Config<S>
    ) => {
    getServerSideProps: <P extends {} = any>(
    callback: GetServerSidePropsCallback<S, P>
    ) => any;
    getStaticProps: <P_1 extends {} = any>(
    callback: GetStaticPropsCallback<S, P_1>
    ) => any;
    getInitialAppProps: <P_2 extends {} = any>(
    callback: AppCallback<S, P_2>
    ) => GetInitialAppProps<P_2>;
    getInitialPageProps: <P_3 extends {} = any>(
    callback: PageCallback<S, P_3>
    ) => (context: any) => any;
    withRedux: (
    Component: NextComponentType | App | any
    ) => {
    new (props: any, context: any): {
    store: S;
    hydrate(
    { initialState, initialProps, ...props }: any,
    context: any
    ): void;
    shouldComponentUpdate(
    nextProps: Readonly<any>,
    nextState: Readonly<any>,
    nextContext: any
    ): boolean;
    render(): any;
    context: any;
    setState<K extends string | number | symbol>(
    state: any,
    callback?: (() => void) | undefined
    ): void;
    forceUpdate(callback?: (() => void) | undefined): void;
    readonly props: Readonly<any> & Readonly<{ children?: React.ReactNode }>;
    state: Readonly<any>;
    refs: { [key: string]: any };
    componentDidMount?(): void;
    componentWillUnmount?(): void;
    componentDidCatch?(error: Error, errorInfo: any): void;
    getSnapshotBeforeUpdate?(
    prevProps: Readonly<any>,
    prevState: Readonly<any>
    ): any;
    componentDidUpdate?(
    prevProps: Readonly<any>,
    prevState: Readonly<any>,
    snapshot?: any
    ): void;
    componentWillMount?(): void;
    UNSAFE_componentWillMount?(): void;
    componentWillReceiveProps?(
    nextProps: Readonly<any>,
    nextContext: any
    ): void;
    UNSAFE_componentWillReceiveProps?(
    nextProps: Readonly<any>,
    nextContext: any
    ): void;
    componentWillUpdate?(
    nextProps: Readonly<any>,
    nextState: Readonly<any>,
    nextContext: any
    ): void;
    UNSAFE_componentWillUpdate?(
    nextProps: Readonly<any>,
    nextState: Readonly<any>,
    nextContext: any
    ): void;
    };
    displayName: string;
    getInitialProps: any;
    contextType?: React.Context<any> | undefined;
    };
    };

      Interfaces

      interface Config

      interface Config<S extends Store> {}

        property debug

        debug?: boolean;

          property deserializeState

          deserializeState?: (state: any) => ReturnType<S['getState']>;

            property serializeState

            serializeState?: (state: ReturnType<S['getState']>) => any;

              interface InitStoreOptions

              interface InitStoreOptions<S extends Store> {}

                property context

                context: Context;

                  property makeStore

                  makeStore: MakeStore<S>;

                    interface WrapperProps

                    interface WrapperProps {}

                      property initialProps

                      initialProps: any;

                        property initialState

                        initialState: any;

                          Type Aliases

                          type AppCallback

                          type AppCallback<S extends Store, P> = (store: S) => GetInitialAppProps<P>;

                            type Callback

                            type Callback<S extends Store, P> =
                            | GetStaticPropsCallback<S, P>
                            | GetServerSidePropsCallback<S, P>
                            | PageCallback<S, P>
                            | AppCallback<S, P>;

                              type Context

                              type Context =
                              | NextPageContext
                              | AppContext
                              | GetStaticPropsContext
                              | GetServerSidePropsContext;

                                type GetServerSidePropsCallback

                                type GetServerSidePropsCallback<S extends Store, P> = (
                                store: S
                                ) => GetServerSideProps<P>;

                                  type GetStaticPropsCallback

                                  type GetStaticPropsCallback<S extends Store, P> = (store: S) => GetStaticProps<P>;

                                    type MakeStore

                                    type MakeStore<S extends Store> = (context: Context) => S;

                                      type PageCallback

                                      type PageCallback<S extends Store, P> = (store: S) => GetInitialPageProps<P>;

                                        Package Files (1)

                                        Dependencies (0)

                                        No dependencies.

                                        Dev Dependencies (18)

                                        Peer Dependencies (3)

                                        Badge

                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/next-redux-wrapper.

                                        • Markdown
                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/next-redux-wrapper)
                                        • HTML
                                          <a href="https://www.jsdocs.io/package/next-redux-wrapper"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>