From 944c9eac83cad407af12ea01bdaa2d123d3d078d Mon Sep 17 00:00:00 2001 From: Alex Gutierrez Date: Thu, 22 Apr 2021 14:41:25 -0700 Subject: [PATCH] fix/refac(list-item/home): refactored list item component to receive a pokemon prop. resolved issue #4 --- src/components/ListItem.tsx | 19 +++++++++---------- src/pages/Home.tsx | 23 ++--------------------- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/src/components/ListItem.tsx b/src/components/ListItem.tsx index 6246bbd..e649e87 100644 --- a/src/components/ListItem.tsx +++ b/src/components/ListItem.tsx @@ -2,24 +2,23 @@ import React from 'react'; import { Link } from 'react-router-dom'; interface ListItemProps { - poke: Pokemon; - index: number; + pokemon: Pokemon; } -const ListItem: React.FC = ({ poke, index }) => { +const ListItem: React.FC = ({ pokemon }) => { return ( -
  • +
  • {/* section img pulled to left */} - {poke.name} + {pokemon.name}

    - {poke.name} + + {pokemon.name} +

    - Height: {poke.height} - Weight: {poke.weight} + Height: {pokemon.height} + Weight: {pokemon.weight}
    {/* section pokemon name that is wrapped in a link */} diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index ac33451..8ac9ca0 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect, ChangeEvent } from 'react'; import { Link } from 'react-router-dom'; import { pokemonData } from '../data/pokemonData'; +import ListItem from '../components/ListItem'; const HomePage: React.FC = () => { const [pokemon, setPokemon] = useState(pokemonData); @@ -52,27 +53,7 @@ const HomePage: React.FC = () => {
      {pokemon.map((poke, index) => { - return ( -
    • - {/* section img pulled to left */} - {poke.name} -
      -

      - - {poke.name} - -

      -
      - Height: {poke.height} - Weight: {poke.weight} -
      -
      - {/* section pokemon name that is wrapped in a link */} - {/* section for details under the pokemon name */} -
    • - ); + return ; })}