Giter Site home page Giter Site logo

imteekay / pokehooks-labs Goto Github PK

View Code? Open in Web Editor NEW
39.0 2.0 15.0 839 KB

A laboratory to use pokemons and do some experiments with React Hooks API

Home Page: https://www.iamtk.co/react-hooks-context-api-and-pokemons

License: MIT License

HTML 11.37% CSS 3.66% JavaScript 84.97%
javascript js react reactjs react-hooks context-api pokemon pokedex

pokehooks-labs's Introduction

pokehooks-labs's People

Contributors

dependabot[bot] avatar imteekay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pokehooks-labs's Issues

Infinite loop

Hi there! I spotted a infinite loop while i was playing with the app in codesandbox.

https://codesandbox.io/s/billowing-wildflower-mm5dd?file=/src/Pokemon/PokemonsList.js

Here is the source of the problem:
image

Inside PokemonContext.js addPokemons must be wrapped with useCallback(...addPokemons, [dispatch]);
const addPokemons = useCallback( pokemons => dispatch({ type: ADD_POKEMONS, pokemons }), [dispatch] );

Also. Inside PokemonList.js you can leave the dependency array of useEffect() empty, so it executes just one time. This way you dont need to use useCallback. :)

I think that the problems is that addPokemons function reference is always being updated when the state in PokemonProvider receive an update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.