title: Don't know how to properly access fetching result in redux state with hooks
body: <p>I'm trying to fetch data from my backend to my redux store to than access it in my functional React Component. (Using hooks instead of classes)</p>
  <p>When I'm trying to fetch the data in the component itself like this:</p>
  <pre><code>useEffect(() =&gt; {
    const fetchCategories = async () =&gt; {
      const res = await trees.get('/categories')
      setCategories(res.data)
    }
  
    fetchCategories()
  }, [])
  </code></pre>
  <p>it works and i have access to the data, but it's obviously not in the redux store, just in my components state. (I have my axios.create in a seperate file, so I can just fetch with tree.get)</p>
  <p>And fetching in my action creator works aswell, I can successfully dispatch the responses data into my redux store like this:</p>
  <pre><code>export const fetchCategories = async () =&gt; {
    const res = await trees.get('/categories')
    dispatch({ type: FETCH_CATEGORIES, payload: res.data })
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/NJzq8.png" rel="nofollow noreferrer">state in my redux store</a></p>
  <p>But I don't know how to properly run my action creator to than access the data in the redux store from my React Component.
  I tried several things like:</p>
  <pre><code>const [categories, setCategories] = useState([{
      &quot;value&quot;: &quot;loading...&quot;,
      &quot;icon&quot;: &quot;music&quot;
    }])
  
    useEffect(() =&gt; {
      const plsWork = async () =&gt; {
        const res = await fetchCategories()
        console.log(res)
      }
  
      plsWork()
    }, [])
  
  </code></pre>
  <p>or the useSelector Hook from redux, but I couldn't figure out a way, that's working. :(</p>