title: Nextjs redux, thunk and getInitialProps - how to implement
body: <p>I want to use <code>nextjs</code> in my new project with <code>redux</code> and <code>thunk</code> also. I wondering how to implement all packages correctly.</p>
  
  <p>In my previous projects pages has <code>HOC</code> components like: </p>
  
  <pre><code>import {connect} from 'react-redux';
  import Page from './about';
  import {fetchUsers} from '../../actions/user';
  
  const mapStateToProps = (state) =&gt; {
      const {users} = state;
      return users;
  };
  
  const mapDispatchToProps = (dispatch) =&gt; {
      return {
          fetchUsers: () =&gt; dispatch(fetchUsers())
      };
  };
  
  export default connect(mapStateToProps, mapDispatchToProps)(Page);
  </code></pre>
  
  <p>And method to fetch users I implemented in <code>componentDidMount</code></p>
  
  <p>How to implement the same logic for <code>nexjs</code>? </p>
  
  <p>What have I do? </p>
  
  <ol>
  <li>Implemented store (base on next-redux-wrapper in _app.js)</li>
  <li>Created <code>HOC</code> component (like below) with <code>mapStateToProps</code> and
  <code>mapDispatchToProps</code></li>
  </ol>
  
  <p>Currently I thinking about use somehow <code>this.props.fetchUsers</code> method into <code>getInitialProps</code> - documentation say that this method should be used to fetch data before render site. </p>
  
  <p>Please help me with correctly <code>redux</code> implementation for <code>nextjs</code></p>