Answer the question
In order to leave comments, you need to log in
How to update State after redux dispatch?
How to update State after redux dispatch?
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);
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question