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

438
Vistas
how do i call my variable so that it shows up on my react web app

i am trying to call

var items = {
   

 Rice: [{ name: "Diri Djon Djon (Black rice)", Price: "$14.00" }],
  };

into one of my DIVS so that i can display the array of food items on this menu web page project that i am doing. Now i know that i am building an array and what i would like to do is display the menu items just like you would using a json file. Im not experienced in doing either as i am just starting with out with react and JavaScript. i know i must be forgetting something as i know i have done this before. i want to just call the data in var items or just items so that it will display the name of the dish and the price Diri Djon Djon (Black rice) $14.00

My full code is down below and this is what i have is react

port default function Home(params) {
  var items = {
    Rice: [{ name: "Diri Djon Djon (Black rice)", Price: "$14.00" }],
  };
  return (
    <>
      {" "}
      <h1>Welcome to the best Hatian Resurant in the City!!</h1>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente atque
        consequatur magnam ex repellat fuga officia corrupti quos distinctio,
        similique ad praesentium assumenda explicabo dolorum ea aperiam ab
        blanditiis voluptatum!
      </p>
      <hr />
      <div className="locate">
        
      </div>
      <div className="address-text">
        <h4></h4>
        <br />
        <div className="phone number">
          <h4></h4>
        </div>
        <div className="container2">
          <img className="image1" src="./images\HaitinFood.png" alt="food" />
        </div>
      </div>
      <div>
        <h1>Menue</h1>
        <h3>ENTRÉES </h3>
        <div className="container2">
          <p>Diri Djon Djon (Black rice) Medium $12 Large $14 </p>
        </div>
      </div>
      <div>{items}</div>
    </>
  );
}

i looked up how to call json files but i was told this way is faster and inline at least i think. Im not sure if i am explaining this correctly but this is the code above and the bottom is what i attempted and all it did was blank out the whole page.

The first image is what i have with my first attempt and the second image is when i remove the <div>{items}</div>

Empty React page

When i remove the div with the {text}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The issue is that the itemsvariable is an object and React cannot render objects, what you need to do is extract the values of your object and create some JSX with it:

<div>
  {items.Rice.map(rice => (
    <div className="container2">
      <p>{rice.name} {rice.price}</p>
    </div>
  ))}
</div>
about 4 years ago · Juan Pablo Isaza Denunciar
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