Skip to content

Commit aa2003f

Browse files
committed
Rewrite in es6
1 parent bddbacf commit aa2003f

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

index.html

-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
<title>MontpellierJS - ToDo List!</title>
66
</head>
77
<body>
8-
98
<div id="app"></div>
10-
119
<script src="build/bundle.js"></script>
12-
1310
</body>
1411
</html>

src/components/Todo.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
var React = require('react');
1+
import React from 'react'
22

3-
function Todo(props) {
3+
export default function Todo(props){
44
return (
55
<li style={{
66
textDecoration: props.completed ? 'line-through' : 'none',
77
cursor: props.completed ? 'default' : 'pointer'
88
}}>
99
{props.text}
1010
</li>
11-
);
12-
}
13-
14-
module.exports = Todo;
11+
)
12+
}

src/components/TodoList.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
var React = require('react');
1+
import React from 'react'
22

3-
var Todo = require('./Todo.js');
3+
import Todo from './Todo'
44

5-
function TodoList(props) {
6-
var data = props.data;
5+
export default function TodoList(props) {
76
return (
87
<div className="TodoList">
98
<ul>
10-
{data.map(function(todo) {
9+
{props.data.map(function(todo) {
1110
return <Todo key={todo.id} completed={todo.completed} text={todo.text} />
1211
})}
1312
</ul>
1413
</div>
15-
);
14+
)
1615
}
17-
18-
module.exports = TodoList;

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ var data = [
77
{id: 2, text: "Add data", completed: 1},
88
]
99

10-
render((<TodoApp data={data}/>),document.getElementById('app'))
10+
render((<TodoApp data={data}/>), document.getElementById('app'))

0 commit comments

Comments
 (0)