Implemented setTypeOptions and setSelectedType at correct place

develop
Jason Zhu 2023-04-12 21:57:02 +10:00
parent e2bbe1d959
commit fd21848a85
1 changed files with 9 additions and 4 deletions

View File

@ -70,14 +70,19 @@ const Filters = () => {
dispatch(setRegionOptions(fetchedRegionOptions));
dispatch(setSortOptions(fetchedSortOptions));
if (!isFetchingTypeOptions && fetchedTypeOptions) {
dispatch(setTypeOptions(fetchedTypeOptions.results));
}
dispatch(setSelectedRegion(fetchedRegionOptions[0].region));
dispatch(fetchPokemonsInTheRegion(fetchedRegionOptions[0].region));
dispatch(setSelectedSort(fetchedSortOptions[0].value));
}, []);
useEffect(() => {
if (!isFetchingTypeOptions && fetchedTypeOptions) {
dispatch(setTypeOptions(fetchedTypeOptions.results));
dispatch(setSelectedType(fetchedTypeOptions.results[0].name));
}
}, [isFetchingTypeOptions]);
const optionElements =
createRegionPokemonListOptionElements(regionPokemonList);