React

by aparadise

HTML

<div id="app"></div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

React

class TodoApp extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
    	items: [
      	{ id:1, text: "Learn JavaScript"},
        { id:13, text: "Learn React" },
        { id:10, text: "Play around in JSFiddle" },
        { id:14, text: "Build something awesome" }
      ]
    }
    /*  if the object does not have any id's you can use the 'i' as a key it will autoincrement*/
    this.myItem = this.state.items.map((item, i) =>
    <div className={i} key={i}>{ item.id } { item.text }</div> );
  }
  

  
  render() {
    return (
      <div>
        { this.myItem }
      </div>
    )
  }
}

ReactDOM.render(<TodoApp />, document.querySelector("#app"))