title: Using React and Redux Hooks, why is my action not firing?
body: <p>Edit: SOLVED! Please see <a href="https://stackoverflow.com/a/59077964/8234403">below</a>.</p>
  
  <p>I want my <code>Blog</code> component to fire the <code>fetchBlog</code> action creator every time the browser requests its URL, be it via a link or a refresh. I'd like to do it with the React <code>useEffect</code> Hook and with the React-Redux <code>useDispatch</code> and <code>useSelector</code> Hooks. However, my action only fires when following the link to the page; I do not understand why, even after reading several explanations (like <a href="https://react-redux.js.org/next/api/hooks#usedispatch" rel="nofollow noreferrer">the official docs</a>).</p>
  
  <p>Here is the code:</p>
  
  <pre class="lang-js prettyprint-override"><code>// Everything duly imported, or else VSC would yell at me
  
  export default function Blog() {
    const dispatch = useDispatch();
      // slug is set here with useSelector, this always works
    useEffect(() =&gt; {
      dispatch(fetchBlog(slug))
    }, [slug, dispatch]);
    const blog = useSelector((state) =&gt; state.blogs[0]);
      // return renders the blog information from the blog constant
      // since the action does not fire, blog is undefined because state.blogs is an empty array
  }
  </code></pre>
  
  <p>I know that, on refresh, <code>fetchBlog</code> does not fire because of Redux DevTools and also because I put a <code>debugger</code> there. (And the back-end logs don't show the request coming in.) The action creator itself and the reducer must be working; if they weren't, the page would not load correctly when visited through a link.</p>
  
  <p>Edit: I have determined <code>useSelector</code> and <code>useDispatch</code> are not the root cause of the problem, as changing the code to use <code>connect</code> with <code>mapStateToProps</code> and <code>mapDispatchToProps</code> gives the same result. The issue seems to be with <code>useEffect</code>.</p>