title: How to use redux hooks in getInitialProps
body: <p>I have been trying to persist my redux store through a reload. I was using useEffect to dispatch my actions at first but then when I tried to reload the page router became undefined and I got a 500 error. After that I tried using getInitialProps and use the ctx.query.id but I ran into another error saying that hooks can only be called inside of the body of a function component.</p>
  <p>How do I make it so hooks work inside of getInitialProps and what is the best way of persisting my store data through a reload?</p>
  <pre><code>export default function CarPage() {
    const dispatch = useDispatch()
    const router = useRouter()
    const car = useSelector((state) =&gt; state.cars.car)
  
    /*
    useEffect(() =&gt; {
      if(!car &amp;&amp; router) {
        dispatch(getCar(router.query.id))
      }
    }, [])
    */
  
    return (
        &lt;Container&gt;
          &lt;h2&gt;{car.model}&lt;/h2&gt;
        &lt;/Container&gt;
    )
  }
  
  CarPage.getInitialProps = async (ctx) =&gt; {
    const dispatch = useDispatch()
    dispatch(getCar(ctx.query.id))
  }
  </code></pre>