/poke-hooks

react hook for pokemon api

Primary LanguageTypeScript

poke-hooks

React Hooks for Pokemon API with Typescript

poke-hooks-example

usePokemon

usePokemon(name: string | number) : {
  data: Pokemon | null;
  isLoading: boolean;
}

Example

import { usePokemon } from "poke-hooks";

const Poke = () => {
  const { data, isLoading } = usePokemon("pikachu"); // set name or number
  if (isLoading) {
    return <div>loading... </div>;
  }
  return (
    <div>
      <p> name: {data.name} </p>
    </div>
  );
};