MCPcopy Create free account
hub / github.com/SuboptimalEng/coding-tutorials / loadTenPokemon

Function loadTenPokemon

react-infinite-scroller/pages/index.jsx:9–18  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7 const [pokemon, setPokemon] = useState([]);
8
9 const loadTenPokemon = () => {
10 const tenPokemon = [];
11 axios
12 .get(`https://pokeapi.co/api/v2/pokemon?limit=10&offset=${currentOffset}`)
13 .then(({ data }) => {
14 data.results.forEach((p) => tenPokemon.push(p.name));
15 setPokemon((pokemon) => [...pokemon, ...tenPokemon]);
16 });
17 currentOffset += 10;
18 };
19
20 const handleScroll = (e) => {
21 console.log(e.target.documentElement.scrollTop);

Callers 2

handleScrollFunction · 0.85
HomeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected