Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
Unable to get images from the images folder using img tag

I am trying to display images for each object inside categoryDictonary and later display it using the html tag <img src=items.image />. However I am unable to get the desired image.
What am I doing wrong?

I would've just used links to images but the links are very very lengthy and they make the code look/feel clumsy as well.
I think its good practice to have a seperate folder for images but I'm unable to implement the same.

import { useState } from "react";
import "./styles.css";

export default function App() {
  var categoryDictonary = {
    Marvel: [
      {
        name: "WandaVision",
        image: "Images/Wanda.jfif",
        rating: 10
      },
      { name: "Loki", image: "Loki.jfif", rating: 9.5 },
      { name: "Moon Knight", image: "Images/MoonKnight.jfif", rating: 8 }
    ],
    SitComs: [
      {
        name: "Brooklyn 99",
        image: "Images/Wanda",
        rating: 10
      },
      {
        name: "Bing Bang Theory",
        image: "Images/Loki",
        rating: 7
      },
      {
        name: "Friends",
        image: "Image/Wanda",
        rating: 7
      }
    ]
  };

  var categories = Object.keys(categoryDictonary);
  var [category, setCategory] = useState("Marvel");
  function ClickHandler({ item }) {
    console.log(item);
    setCategory(item);
    console.log("Categoty is" + category);
  }

  return (
    <div className="App">
      <h2>TV Show Ratings</h2>
      <h3>Check out my ratings on some of the most popular TV Shows</h3>
      <ul>
        {categories.map((item) => {
          return (
            <li
              id="Categories"
              key={item}
              onClick={() => ClickHandler({ item })}
            >
              {item}
            </li>
          );
        })}
      </ul>
//List to display all shows of a given category
      <ul id="ShowList">
        {categoryDictonary[category].map((items) => {
          return (
            <li id="Shows" key={items.name}>
//Gives the name of the show
              <div>{items.name}</div>
//Gives the image of the show
              <div>
                <img src={items.image} />
              </div>
//Gives the rating of the show
              <div>Rating:{items.rating}</div>
            </li>
          );
        })}
      </ul>
    </div>
  );
}

Here is the corresponding output to my code:

Current output of my code

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda