Poké-Dictionary

A React Native app for looking up pokemon using the PokéAPI, created by Zaki Refai.

icon

Goal Of The Project

Experiment with local caching and optimization techniques to provide a seamless solution for easy look up of any of the 890 pokemon.

In Action

Searching

gif 1

Details

gif 1

Favorites

gif 2

Technologies

React Native, PokéAPI, Redux, Redux Persist, Fuse.js, Axios

How does it work?

Fetching and AsyncStorage

On a fresh download, the app will fetch any new pokemon from the PokéAPI and store it in AsyncStorage. If there is ever a re-render required of a pokemon in the search list or its details, it will fetch that data from AsyncStorage instead of fetching the data from the API. New pokemon data is always fetched and stored on initial render, but retrieved from device memory every time after. This makes renders quick, and it’s an efficient way for handling repeat renders of the same pokemon during searching. I had initially thought to use Redux as a container over AsyncStorage for this portion of the app. It’s good practice to do so, but state management was not necessary for Pokemon lookup, their details, or moves.

Redux

However, there are places that use Redux: Unown Mode and the Favorites List. Unown Mode requires re-rendering every rendered element with Unown formatted text. To achieve this, I created a function that acted as a funnel for all text formatting in the app. When the switch is made to Unown Mode, the value is changed in Redux causing cascade re-renders in the search list (Unown mode also required different padding from the normal font, and this adjustment is accounted for). The Favorites List acts in the same way. Whenever a pokemon is added to the list an action is fired through dispatch and the list is updated in Redux. Any change to the redux state will cause the Favorites List to re-render; actions like add or removing from the list cause this.

Component Reuse

The code for this app is condensed as much as possible. Components like PokemonCard, PokemonDetails, and PokemonMoves in the search list are reused in the Favorites List as well. The PokemonTypes component has attributes (flags) for different styles of PokemonType; this component appears in PokemonCard, PokemonDetails, and PokemonMoves. In terms of fetching data, the useSearch hook was generalized enough to be used in multiple places.

Fun Learning Experiences From The App

WHAT ?!?

gif 3