react render a list code example

Example 1: how to get element from arraylist react

function NonIdiomaticList(props) {
  // Build an array of items
  let array = [];
  for(let i = 0; i < props.items.length; i++) {
    array.push(
      <Item key={i} item={props.items[i]} />
    );
  }

  // Render it
  return (
    <div>
      {array}
    </div>
  );
}

Example 2: react create list of array in react

const App = props => {  const quoteArray = props.quotes.map((quote) => {    return (      <Quote text={quote.text} author={quote.author} />    );  });  return (    <div>      <h2>Famous Quotes</h2>      {quoteArray}    </div>  );};App.propTypes = {  quotes: React.PropTypes.array}