Skip to content

Commit

Permalink
update example for map/key
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbergqvist committed Mar 3, 2021
1 parent 870b27c commit 944ddcf
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions react-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,22 @@ export default UserEventComponent;
## Map + Keys
```javascript
import React from 'react';

const ComponentWithList = (items) => {
return (
<h1>Awesome people list</h1>
<ul>
{items.map(item => {
return (
<li key={item.id}>
{item.name}
</li>
)
})}
</ul>
);
}

export default ComponentWithList;
import React from "react";

const ComponentWithList = ({ items }) => {
return (
<>
<h1>Awesome people list</h1>
<ul>
{items.map((item) => {
return <li key={item.id}>{item.name}</li>;
})}
</ul>
</>
);
};

export default ComponentWithList;
```
```javascript
Expand Down

0 comments on commit 944ddcf

Please sign in to comment.