Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

437
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!