Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

439
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda