Skip to content

Commit 5b826ab

Browse files
committed
use es6 class syntax
1 parent f77f608 commit 5b826ab

File tree

9 files changed

+39
-35
lines changed

9 files changed

+39
-35
lines changed

app/scripts/actions/itemActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ ItemActions.loadItems.preEmit = function(data){
1818
},500);
1919
};
2020

21-
module.exports = ItemActions;
21+
export default ItemActions;

app/scripts/components/header.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { Link } from 'react-router';
33

4-
var Header = React.createClass({
4+
class Header extends React.Component{
55

66
render() {
77
return (
@@ -20,6 +20,6 @@ var Header = React.createClass({
2020
);
2121
}
2222

23-
});
23+
}
2424

25-
module.exports = Header;
25+
export default Header;

app/scripts/components/itemList.jsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React from 'react';
22

3-
var ItemList = React.createClass({
4-
5-
propTypes: {
6-
loading : React.PropTypes.bool,
7-
items : React.PropTypes.array
8-
},
3+
class ItemList extends React.Component {
4+
5+
constructor(){
6+
super();
7+
}
98

109
render() {
1110
var items = this.props.items.map(item => <li key={ item }>{ item }</li>),
@@ -21,6 +20,11 @@ var ItemList = React.createClass({
2120
);
2221
}
2322

24-
});
23+
}
24+
25+
ItemList.propTypes = {
26+
loading : React.PropTypes.bool,
27+
items : React.PropTypes.array
28+
}
2529

26-
module.exports = ItemList;
30+
export default ItemList;

app/scripts/pages/app.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { RouteHandler } from 'react-router';
33
import Header from '../components/header.jsx'
44

5-
var App = React.createClass({
5+
class App extends React.Component {
66

77
render() {
88
return (
@@ -15,6 +15,6 @@ var App = React.createClass({
1515
);
1616
}
1717

18-
});
18+
}
1919

20-
module.exports = App;
20+
export default App;

app/scripts/pages/home.jsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@ import ItemList from '../components/itemList.jsx';
33
import ItemStore from '../stores/itemStore';
44
import ItemActions from '../actions/itemActions';
55

6-
var Home = React.createClass({
6+
class Home extends React.Component {
77

8-
getInitialState() {
9-
return {
8+
constructor(props){
9+
super(props);
10+
this.state = {
1011
items : [],
1112
loading: false
12-
}
13-
},
13+
};
14+
}
1415

1516
componentDidMount() {
16-
this.unsubscribe = ItemStore.listen(this.onStatusChange);
17+
this.unsubscribe = ItemStore.listen(this.onStatusChange.bind(this));
1718
ItemActions.loadItems();
18-
},
19+
}
1920

2021
componentWillUnmount() {
2122
this.unsubscribe();
22-
},
23+
}
2324

2425
onStatusChange(state) {
2526
this.setState(state);
26-
},
27+
}
2728

2829
render() {
2930

@@ -34,7 +35,6 @@ var Home = React.createClass({
3435
</div>
3536
);
3637
}
38+
}
3739

38-
});
39-
40-
module.exports = Home;
40+
export default Home;

app/scripts/pages/info.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
var Info = React.createClass({
3+
class Info extends React.Component {
44

55
render() {
66
return (
@@ -15,6 +15,6 @@ var Info = React.createClass({
1515
);
1616
}
1717

18-
});
18+
}
1919

20-
module.exports = Info;
20+
export default Info;

app/scripts/pages/notFound.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
var NotFound = React.createClass({
3+
class NotFound extends React.Component {
44

55
render() {
66
return (
@@ -11,6 +11,6 @@ var NotFound = React.createClass({
1111
);
1212
}
1313

14-
});
14+
}
1515

16-
module.exports = NotFound;
16+
export default NotFound;

app/scripts/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ var routes = (
1515
</Route>
1616
);
1717

18-
module.exports = routes;
18+
export default routes;

app/scripts/stores/itemStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ var ItemStore = Reflux.createStore({
3535

3636
});
3737

38-
module.exports = ItemStore;
38+
export default ItemStore;

0 commit comments

Comments
 (0)