Reputation: 3
I try to learning react.js and stuck on get specific result on map. here is the code
render(){
const friends = [
{id:1, name: 'Dave',age:50},
{id:2,name: 'Kellie',age:42},
{id:3,name: 'Max',age:12},
{id:2,name: 'Jack',age:12}
];
return(
<div>
<ul>
{friends.map(p => <li key={p.id}>{p.name}</li>)}
</ul>;
</div>
);
result:
*Dave
*Kellie
*Max
*Jack
how to get result like this with map?
*Dave *Kellie
*Max *Jack
and how to get result from specific range on index like this?
*Max *Jack
thank you.
Upvotes: 0
Views: 48
Reputation: 3476
map
isn't a react-js specific function, it's native to the javascript array - See the MDN page.
How you want to work out your list formatting is up to you. One answer suggests using css3.
Getting a specific result is as simple as using slice
e.g. friends.slice(2).map(...)
Upvotes: 1