I\'m working on a react project to learn react.
In a component\'s render method, when I use .map to iterate over values and return an array of component
.map
If you only want to use one pass over the array you can use reduce:
books && books .reduce( (all,book, index) => { if (book.shelf !== shelf) { return all; } return all.concat( ); } ,[] )
However; I think using filter and map makes for code that's easier to read.
filter
map