Added setTypeOptions in useEffect()

develop
Jason Zhu 2023-04-11 18:46:48 +10:00
parent 1801e43192
commit 968c6c5d95
1 changed files with 5 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import {
fetchPokemonsInTheRegion, fetchPokemonsInTheRegion,
setRegionOptions, setRegionOptions,
setSortOptions, setSortOptions,
setTypeOptions,
} from 'features/Pokedex/pokedexSlice'; } from 'features/Pokedex/pokedexSlice';
import { RegionPokemonRange } from 'features/Pokedex/types/slice'; import { RegionPokemonRange } from 'features/Pokedex/types/slice';
import { useAppDispatch, useAppSelector } from 'app/hooks'; import { useAppDispatch, useAppSelector } from 'app/hooks';
@ -69,6 +70,10 @@ const Filters = () => {
dispatch(setRegionOptions(fetchedRegionOptions)); dispatch(setRegionOptions(fetchedRegionOptions));
dispatch(setSortOptions(fetchedSortOptions)); dispatch(setSortOptions(fetchedSortOptions));
if (!isFetchingTypeOptions && fetchedTypeOptions) {
dispatch(setTypeOptions(fetchedTypeOptions.results));
}
dispatch(setSelectedRegion(fetchedRegionOptions[0].region)); dispatch(setSelectedRegion(fetchedRegionOptions[0].region));
dispatch(fetchPokemonsInTheRegion(fetchedRegionOptions[0].region)); dispatch(fetchPokemonsInTheRegion(fetchedRegionOptions[0].region));
}, []); }, []);