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

193
Views
How to display object in ReactJS
const nearestLocation: {
    location: {
        lat: number;
        lng: number;
    };
    distance: number;
}

How to display object in browser React Js

output

{location: {…}, distance: 15156172.809947284}
distance: 15156172.809947284
location:
lat: -6.519093935774685
lng: 110.9042735749676
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can stringify the object using JSON.stringify and render it in a pre element.

function App() {
  const nearestLocation = {
    location: { lat: -6.519093935774685, lng: 110.9042735749676 },
    distance: 15156172.809947284,
  };

  return <pre>{JSON.stringify(nearestLocation, null, 2)}</pre>;
}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
<script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<div id="root"></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!