I have a simple React component like so:
import React from 'react';
const ListPage = ({todos}) => (
<div>
<h6>todos</h6>
<ul>
{todos.map(({todo, index}) => (
<li key={index}>{todo}</li>
))}
</ul>
</div>
)
ListPage.propTypes = {
todos: React.PropTypes.array,
};
export default ListPage;
I can see that the docs for Array.prototype.map() shows that the second argument is index, next to currentValue. How does one alter the existing code to pick up the second argument?