Created
October 23, 2019 08:29
-
-
Save react-ram/977f69cba4b646f0f58d0c5e48397551 to your computer and use it in GitHub Desktop.
Basics - Lists and keys example 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
export class App extends Component { | |
render() { | |
const numbers = [1, 2, 3, 4, 5]; | |
return ( | |
<div> | |
<NumbersList numbers={numbers} /> | |
</div> | |
); | |
} | |
} | |
function NumbersList(props) { | |
const numbers = props.numbers; | |
const listitems = numbers.map(number => ( | |
<li key={number.toString()}>{number}</li> | |
)); | |
return <ul>{listitems}</ul>; | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment