-
-
Save antronic/154e3fbda3057c2bed38a62ae0eccf0c to your computer and use it in GitHub Desktop.
pokedex-react-2.js
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
// 3. set render function | |
var render = function() { | |
var filterPokemonType = store.getState().pokemonType; | |
var filterPokemonAtk = store.getState().pokemonAtk; | |
var filterPokemon = filterPokemonByTypeAndMinAtk(allPokemons, filterPokemonType, filterPokemonAtk); | |
ReactDOM.render( | |
<div> | |
<div>--- Total Filter Pokemon: {filterPokemon.length} ---</div> | |
<ul> | |
{filterPokemon.map(function(item, i) { | |
return <li key={i}>{item.name} (Atk: {item.attack}, Def: {item.defense})</li> | |
})} | |
</ul> | |
</div>, | |
document.getElementById('reactOutput') | |
); | |
}; | |
// 4. subscribe render function when state changes | |
store.subscribe(render); | |
render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment