const dispatch= useDispatch();
const [places,setPlaces] = useState([]);
useEffect(() => {
if(bounds.sw && bounds.ne){
getPlacesData(type,bounds.sw,bounds.ne)
.then((data) => {
console.log({data});
setPlaces(data.filter((place) => place.name && place.num_reviews > 0));
console.log({places});
dispatch(setGlobalPlaces(places))
});
}
},[type,bounds])
Getting empty places array in console even after setting places using setPlaces. Only after change in type or change in bounds, "places" hook is getting updated.