React
by Allie Yu
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.0/umd/react.production.min.js"></script>
<div id="root"></div>
React
class TodoApp extends React.Component {
constructor(props) {
super(props)
this.state = {
items: [
{ text: "Learn JavaScript", done: false },
{ text: "Learn React", done: false },
{ text: "Play around in JSFiddle", done: true },
{ text: "Build something awesome", done: true }
]
}
}
render() {
return (
<div>
<h2>Todos:</h2>
<ol>
{this.state.items.map((item,idx) => (
<li key={idx}>
<label>
<input type="checkbox"/>
<span className={item.done ? "done" : ""}>{item.text}</span>
</label>
</li>
))}
</ol>
</div>
)
}
}
ReactDOM.render(<TodoApp />, document.getElementById("root"))