how to display an array element wise in a component of React js?

6.2k Views Asked by At

Hi I have a response coming from an API as a JSON ["a","b","c"]. I want to display this json Element Wise in a React Component. I have converted the JSON into array. I am able to display the whole JSON and array as a whole on the component but not able to display it element wise.

In javascript i used to put a for loop and display all element by document.write but I want to know how to do so in REACT JS.

1

There are 1 best solutions below

3
On BEST ANSWER

In the render() function:

<ul>
{yourArray.map((item,index) => 
    <li key={index}>{item}</li>
)}
</ul>

Is this what you want to do?