nextjs using redux staet code example

Example: next js create store

//Now, we create our _app.js file in pages directory. Add the following lines of code.

import React from "react";
import App, { Container } from "next/app";
import { Provider } from "react-redux";
import withRedux from "next-redux-wrapper";
import { initStore } from "../state/store";


class MyApp extends App {
   static async getInitialProps({ Component, ctx }) {
       const pageProps = Component.getInitialProps
           ? await Component.getInitialProps(ctx)
           : {};
            return { pageProps };
   }


   render() {
       const { Component, pageProps, store } = this.props;
       return (
           <Container>
               <Provider store={store}>
                   <Component {...pageProps} />
               </Provider>
           </Container>
       );
   }
}


export default withRedux(initStore)(MyApp);