Skip to content

Instantly share code, notes, and snippets.

@antronic
Forked from chaintng/pokedex-react-2.js
Created August 19, 2016 10:54
Show Gist options
  • Save antronic/154e3fbda3057c2bed38a62ae0eccf0c to your computer and use it in GitHub Desktop.
Save antronic/154e3fbda3057c2bed38a62ae0eccf0c to your computer and use it in GitHub Desktop.
pokedex-react-2.js
// 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