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

203
Views
Getting data attribute from root in ReactJs

I'm trying to grab the attribute listed in the div being rendered but it returns undefined. Any idea on how to go about it will be greatly appreciated

index.html

  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root" data-username="mark"></div>
  </body>

index.js

const root = ReactDOM.createRoot(document.getElementById("root"));
if (root) {
  console.log(root.dataset)
  root.render(
    <React.StrictMode>
      <App />
    </React.StrictMode>
  );
}
about 4 years ago · Juan Pablo Isaza
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!