diff --git a/src/features/Pokedex/Filters/Filters.tsx b/src/features/Pokedex/Filters/Filters.tsx index b3b3a22..0be10bc 100644 --- a/src/features/Pokedex/Filters/Filters.tsx +++ b/src/features/Pokedex/Filters/Filters.tsx @@ -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);