developer_beginning
developer_beginning

Reputation: 393

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

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.

Upvotes: 3

Views: 6231

Answers (1)

Zhang Chao
Zhang Chao

Reputation: 757

In the render() function:

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

Is this what you want to do?

Upvotes: 5

Related Questions