Created
March 7, 2020 19:29
-
-
Save vhuerta/3b34eb5c12be9abdb51886ee84e9501f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// REDUCER | |
function reducer(state: PokemonState, action: PokemonAction): PokemonState { | |
switch (action.type) { | |
case "FETCH_POKEMON_PENDING": | |
return { ...state, isLoading: true }; | |
case "FETCH_POKEMON_COMPLETED": | |
return { ...state, isLoading: false, pokemons: action.pokemons }; | |
case "FETCH_POKEMON_FAILED": | |
return { ...state, isLoading: false, pokemons: [] }; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment