title: I got server error when use next.js , Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>
body: <p>I use next.js ssr ,and I got server error, my code like this:
  Error: could not find react-redux context value; please ensure the component is wrapped in a </p>
  <p>I surpose my code somthing use error, but I don't know how to fix?</p>
  <p>in my Header.jsx:</p>
  <pre><code>import React from 'react'
  import {
    useSelector,
  } from 'react-redux'
  
  const Header = props =&gt; {
    const user = useSelector(state =&gt; state.getIn(['header', 'user']).toJS())
    return (
      &lt;div&gt;...&lt;/div&gt;
    )
  }
  export default Header
  </code></pre>
  <p>in my _app.jsx:</p>
  <pre><code>import App, { Container } from 'next/app'
  import 'antd/dist/antd.css'
  import React from 'react'
  import { Provider } from 'react-redux'
  import Layout from '../components/Layout'
  import withRedux from '../lib/with-redux-app'
  
  class MyApp extends App {
  
    static async getInitialProps(ctx) {
  
      const { Component } = ctx
      let pageProps = {}
      if (Component.getInitialProps) {
       pageProps = await Component.getInitialProps(ctx)
      }
  
      return {
        pageProps,
      }
    }
  
    render() {
      const { Component, pageProps, reduxStore } = this.props
      return (
        &lt;Container&gt;
          &lt;Layout&gt;
            &lt;Provider store={reduxStore}&gt;
              &lt;Component {...pageProps} /&gt;
            &lt;/Provider&gt;
          &lt;/Layout&gt;
        &lt;/Container&gt;
      )
    }
  }
  
  export default withRedux(MyApp)
  </code></pre>
  <p>in my with-redux-app.jsx</p>
  <pre><code>import React from 'react'
  import initializeStore from '../redux/store'
  
  const isServer = typeof window === 'undefined'
  const __NEXT_REDUX_STORE__ = '__NEXT_REDUX_STORE__'
  
  function getOrCreateStore(initialState) {
    if (isServer) {
      return initializeStore(initialState)
    }
  
    if (!window[__NEXT_REDUX_STORE__]) {
      window[__NEXT_REDUX_STORE__] = initializeStore(initialState)
    }
    return window[__NEXT_REDUX_STORE__]
  }
  
  export default Comp =&gt; {
    class withReduxApp extends React.Component {
      constructor(props) {
        super(props)
        this.reduxStore = getOrCreateStore(props.initialReduxState)
      }
  
      render() {
        const { Component, pageProps, ...rest } = this.props
        return (
          &lt;Comp
            {...rest}
            Component={Component}
            pageProps={pageProps}
            reduxStore={this.reduxStore}
          /&gt;
        )
      }
    }
  
    withReduxApp.getInitialProps = async ctx =&gt; {
      const reduxStore = getOrCreateStore()
      ctx.reduxStore = reduxStore
  
      let appProps = {}
      if (typeof Comp.getInitialProps === 'function') {
        appProps = await Comp.getInitialProps(ctx)
      }
  
      return {
        ...appProps,
        initialReduxState: reduxStore.getState(),
      }
    }
  
    return withReduxApp
  }
  </code></pre>
  <p>and I got server error :
  <a href="https://i.stack.imgur.com/KAnKG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KAnKG.png" alt="enter image description here" /></a></p>
  <p>how can I do ?</p>