---
title: DataList
tags: components,array,beginner
---
Renders a list of elements from an array of primitives.
- Use the value of the `isOrdered` prop to conditionally render a `
` or `` list.
- Use `Array.prototype.map` to render every item in `data` as a `- ` element, give it a `key` produced from the concatenation of the its index and value.
- Omit the `isOrdered` prop to render a `
` list by default.
```jsx
function DataList({ isOrdered, data }) {
const list = data.map((val, i) => - {val}
);
return isOrdered ? {list}
: ;
}
```
```jsx
const names = ['John', 'Paul', 'Mary'];
ReactDOM.render(, document.getElementById('root'));
ReactDOM.render(, document.getElementById('root'));
```