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

188
Views
how can i add an array of html tags to jsx

I am new in react and I have an issue that I didn't find any solution for after search.

When I store the array of html tags in variable I get minified React error #31

var k = [1,2,3];
var x = k.map(e=><li>{e}</li>);
var e = (
  <div>         
    <ul>
      {1 && {x}}
    <ul>
  </div>
);
var divTag = document.getElementById("k");
ReactDOM.render(e,divTag)

But when I write this I get no errors.

var k = [1,2,3];
var x = k.map(e=><li>{e}</li>);
var e = (
  <div>         
    <ul>
      {1 && k.map(e=><li>{e}</li>)}
    <ul>
  </div>
);
var divTag = document.getElementById("k");
ReactDOM.render(e,divTag)
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need to remove the curly braces around the x variable {1 && {x}} -> {1 && x}

You are defining a new object containing the key x instead of just passing the array to react

about 4 years ago · Juan Pablo Isaza Report

0

The solution

Replace {1 && {x}} with {1 && x}

Because you've wrapped x into curly braces, you've got the rendering error (you wanted to provide the array).

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!