title: useSelector Returning Undefined object
body: <p>I am trying to store users fetched by random users api and trying to dispatch it to my store i have store users with an empty array, when i am trying to get users using useSelector i am getting an undefined object.
  Here is my store.js:</p>
  <pre><code>import { configureStore } from &quot;@reduxjs/toolkit&quot;;
  import counterReducer from &quot;../features/counter/counterSlice&quot;;
  import userReducer from &quot;../features/users/userSlice&quot;;
  
  export const store = configureStore({
      reducer: {
          counter: counterReducer,
          user: userReducer,
      },
  });
  </code></pre>
  <p>Here is userSlice.js</p>
  <pre><code>import { createSlice } from &quot;@reduxjs/toolkit&quot;;
  
  export const userSlice = createSlice({
      name: &quot;users&quot;,
      initialState: {
          userArray: [],
      },
      reducers: {
          getUsers: (state, action) =&gt; {
              state.userArray = action.payload;
          }
      }
  })
  
  export const { getUsers } = userSlice.actions;
  export const selectUsers = (state) =&gt; state.users.userArray;
  export default userSlice.reducer;
  </code></pre>
  <p>Here is App.js</p>
  <pre><code>import logo from './logo.svg';
  import './App.css';
  import {useSelector, useDispatch } from 'react-redux';
  import { getUsers, selectUsers } from './features/users/userSlice';
  
  function App() {
    const dispatch = useDispatch();
    const users = useSelector(selectUsers);
  
    const fetchUsers = async () =&gt; {
      fetch(&quot;https://gorest.co.in/public/v2/users&quot;)
        .then((response) =&gt; response.json())
        .then((data) =&gt; {
            console.log(&quot;data=====&quot;, data);
            dispatch(getUsers(data));
        });
    };
  
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;header className=&quot;App-header&quot;&gt;
          &lt;button onClick={fetchUsers}&gt;Get Users&lt;/button&gt;
          {users.length &gt; 0 &amp;&amp;
            users.map((user) =&gt; {
              &lt;li&gt;user.name&lt;/li&gt;;
            })}
        &lt;/header&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>