title: How to display fetched data in functional react-redux component?
body: <p>Why I see always &quot;loading...&quot;?
  I used redux-toolkit and createSlice and fetch data by axios.
  I have not any problem by fetching data and my data is in State.
  My problem is displaying fetched data.
  My Component code is:</p>
  <pre><code>import React, {useEffect, useState} from 'react';
  import { useDispatch, useSelector } from 'react-redux';    
  import {fetchTrackers} from 'dashboard/dashboardSlice';    
  export default function TrackerManagerDashboard() {
      const [trackersList, setTrackersList] = useState(useSelector(state =&gt; state.trackersData));
      const [activeTracker, setActiveTracker] = useState(useSelector(state =&gt; state.activeTracker));
      const dispatch = useDispatch();
      useEffect(() =&gt; {
          dispatch(fetchTrackers);
      }, []);
     if(!trackersList)
          return (
              &lt;div&gt;loading...&lt;/div&gt;
          )
      return (
          &lt;div className=&quot;TrackerManagerDashboard&quot;&gt;
              ...
          &lt;/div&gt;
      )
  }
  </code></pre>
  <p>and reducer Slice file is:</p>
  <pre><code>import { createSlice } from '@reduxjs/toolkit'
  import * as env from &quot;../../environments&quot;;
  import axios from 'axios';    
  const initialState = {
      trackersData: {},
      activeTracker: {},
  }   
  const dashboardSlice = createSlice({
      name: 'dashboard',
      initialState,
      reducers: {
          setInitialState(state, action) {
              state.trackersData = action.payload.data;
              state.activeTracker = state.trackersData[Object.keys(state.trackersData)[0]];
          },
      },
  })    
  export async function fetchTrackers (dispatch, getState) {
      try {
          const { data } = await axios.get(env.APP_URL + '/fetch/trackers.json');
          dispatch(setInitialState({type: 'setInitialState', data }));
      } catch(error) {
          console.log(error);
      }
  }    
  export const { setInitialState} = dashboardSlice.actions
  export default dashboardSlice.reducer
  </code></pre>