title: React Hook useEffect issue with setState
body: <p>I am using useState which has 2 array imageList and videoList and then in useEffect hook i am using forEach on data then if type is image then push to item to image .
  But at last i am not getting imagelist or video list of array.</p>
  
  <pre><code>const [list, setDataType] = useState({imageList:[], videoList:[] });
    useEffect (()=&gt;{
      //data is list of array
        dataList.forEach(item =&gt;{
  
         if(!item.images)  {
           setDataType({...list, imageList:item})
         } 
         else if (item.images[0].type === "video/mp4")
         {
          setDataType({...list, videoList :item})
         }
         else if((item.images[0].type === "images/gpeg")
         {
            setDataType({...list, imageList:item})
         }
        })
    },);
  </code></pre>
  
  <p>Here type check is working correctly but at last i get last fetch data only which can be videolist or imageList
  In last i should get list of all imageList whose type is image and same video list whose type is video </p>