title: useSelector function is not updating the state of after dispatch function -react hooks
body: <p>I am performing an authentication module where I when I click the sign in button , I am verifying user present is MySQL db or not . I am dispatching the function in here in sign in page</p>
  
  <p>Basically when I dispatch it , the null state of the rSignedIn is not changed immediately after dispatch function. I am completely using react hooks. Please help me solve this , I have been trying this for three days.</p>
  
  <p>But the rSignedIn state value updates when I click the login button again, in general , the when I use the state value using the useSelector the value is updated  the second the time when the handleLogin() is invoked</p>
  
  <pre><code>//Sign in Page
  
  ...
  ...
  
  const status=useSelector((state)=&gt;state);
  ...
  ...
  const handleLogin=(event)=&gt;{
        dispatch(LoginUser(loginData));
        console.log(status.auth.rSignedIn);
        if(status.auth.rSignedIn){
          console.log("LOGIN success");
          History.push('/');
        }else{
          console.log("LoginFailed") ;
        }
      }
  
  </code></pre>
  
  <p>this is the action index page where I sent a request to MySQL db , then if there is a response I am dispatching it else an error.</p>
  
  <pre><code>export const LoginUser=(loginData)=&gt;async(dispatch)=&gt;{
      await mysqlDB.post('/fetch/retreive',loginData)
      .then((response)=&gt;dispatch({type:ActionTypes.LOGIN_SUCCESS,payload:response.data}))
      .catch((error)=&gt;dispatch({type:ActionTypes.LOGIN_FAILED}))
  }
  </code></pre>
  
  <p>This is my Reducer for this :</p>
  
  <pre><code>const initialState = {
      gSignedIn:null,
      userId:null,
      registered:null,
      data:null,
      rSignedIn:null,
  }
  
  
  export default (state=initialState,action)=&gt;{
      switch (action.type){
          case ActionTypes.GSIGN_IN:
              return {...state,gSignedIn:true,userId: action.payload};
          case ActionTypes.GSIGN_OUT:
              return {...state,gSignedIn:false,userId:null};
          case ActionTypes.REGISTER_SUCCESS:
              return {...state,registered:true,data: action.payload};
          case ActionTypes.REGISTER_FAILED:
              return {...state,registered:false,data:null};
          case ActionTypes.LOGIN_SUCCESS:
              return {...state,rSignedIn:true,data: action.payload};
          case ActionTypes.LOGIN_FAILED:
              return {...state,rSignedIn:false,data:null};
          case ActionTypes.LOGOUT:
              return {...state,rSignedIn:false,data:null};
          default:
              return state;
      }
  };
  </code></pre>