In my application, I am listing pokemon
from backend. After the pokemons listed in the pokemon-list
component, on click on any of the pokemon I am trying to show the details of the same.
But the whole data disappears suddenly on click of view details
button. I am unable to understand the correct approach to implement the Redux store. What is the proper way to implement the same?
I require:
pokemons
need to listed in the list componentpokemon
pokemons
as like page load, without any backend call.I am new to Redux and React.
I forge to pass the reset of the properties with reducer. when the view details requested, list of user missed, since i did not pass the previous states. it works for me:
const pokemonReducer = (state = initialState, action: PokemonDispatchTypes) => {
switch (action.type) {
case POKEMON_FAIL:
return { loading: false };
case POKEMON_LOADING:
return { loading: true };
case POKERMON_SUCCESS:
return { loading: false, pokemons: action.payload };
case POKEMON_DETAILS:
return { ...state, loading: false, showPokemon: action.payload };//mistake is here
default:
break;
}
return state;
};