(state) => state?.clientAddress?.getAddress
);
useEffect(() => {
dispatch(GET_CLIENT_ADDRESS({}))
}, [dispatch]);
const onSavedAddressSelect = (addressId) => {
debugger
if (addressId) {
const { data: selectedAddress = [] } = clientAddress ?? {} ;
console.clear()
console.log(selectedAddress)
const addressObj = selectedAddress?.filter(
(addressItem) => addressItem?.value === addressId
)?.[0];
setAddress(addressObj);
setSelectedVenue(addressObj?.value);
}
props.drawer.setDrawer({
open: false,
});
};
即使我在useEffect的第一次渲染时进行调度,onSavedAddressSelect中的clientAddress也不会更新为最新的redux状态。请帮忙。
不是clientAddress
没有更新,因为您调用dispatch(GET_CLIENT_ADDRESS({}))
有空对象,所以它保持不变?尝试将一些值为的对象传递到那里