Skip to content

Instantly share code, notes, and snippets.

@react-ram
Created October 23, 2019 08:44
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/ecfb804fb02fe1df4220aa6aca776b56 to your computer and use it in GitHub Desktop.
Save react-ram/ecfb804fb02fe1df4220aa6aca776b56 to your computer and use it in GitHub Desktop.
Basics - Lists & keys example 2.
import React, { Component } from "react";
export class App extends Component {
render() {
const todos = [
{ id: 1, text: "do something" },
{ id: 2, text: "do something else" },
{ id: 3, text: "do nothing" }
];
const todoItems = todos.map(todo => <li key={todo.id}>{todo.text}</li>);
return <div>{todoItems}</div>;
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment