From 968c6c5d95b100292e74a12a915bb1c4927a39e0 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Tue, 11 Apr 2023 18:46:48 +1000 Subject: [PATCH] Added setTypeOptions in useEffect() --- src/features/Pokedex/Filters/Filters.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/features/Pokedex/Filters/Filters.tsx b/src/features/Pokedex/Filters/Filters.tsx index 4122892..b3b3a22 100644 --- a/src/features/Pokedex/Filters/Filters.tsx +++ b/src/features/Pokedex/Filters/Filters.tsx @@ -7,6 +7,7 @@ import { fetchPokemonsInTheRegion, setRegionOptions, setSortOptions, + setTypeOptions, } from 'features/Pokedex/pokedexSlice'; import { RegionPokemonRange } from 'features/Pokedex/types/slice'; import { useAppDispatch, useAppSelector } from 'app/hooks'; @@ -69,6 +70,10 @@ 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)); }, []);