Как после redux dispatch обновить State?
const onChangeCountry = async (id:string) => {
const index = countries?.findIndex((arr) => arr.id === Number(id));
if (countries && !countries[Number(index)].cities) {
const res = await GeoService.getCities(id, 'ru');
if (res.success) {
dispatch(setCities({ index, cities: res.cities }));
}
}
if (countries) setCityList(countries[Number(index)].cities);
};
После выбора страны в Select подгружаю города в redux и пытаюсь положить города в State чтобы вывести в другом Select. но не выходит, очевидно dispactch не успевает сработать, так как если повторно выбрать страну то все подгружается, как быть?