Skip to content

Instantly share code, notes, and snippets.

@react-ram
Created October 23, 2019 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save react-ram/977f69cba4b646f0f58d0c5e48397551 to your computer and use it in GitHub Desktop.
Save react-ram/977f69cba4b646f0f58d0c5e48397551 to your computer and use it in GitHub Desktop.
Basics - Lists and keys example 1.
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