title: Unable to set state hook using useDispatch hook in React
body: <p>I am using useEffect hook to dispatch action to my redux store on component load. Here is code:</p>
  
  <pre><code>const dispatch = useDispatch()
  const hotelList = useSelector(state =&gt; state.hotels)
  const [updatedList, setUpdatedList] = useState([...hotelList])
  
  useEffect(() =&gt; {
      dispatch(fetchHotels())
  // setUpdatedList(hotelList) -- I've tried using this line here but still gets empty array
    }, [])
  </code></pre>
  
  <p>It works fine because when I try to do <code>{console.log(hotelList}</code> I get array of objects from the redux store.</p>
  
  <p>However, when I try to do <code>setUpdatedList(hotelList)</code> or even set initial state it does not work and I get empty array. How can I fix it?</p>
  
  <p>P.S just to clarify I am 100% sure that action was correctly dispatched to the store as I can see the results in console.log as well as in redux dev tools.</p>