Skip to content

Commit 5e87896

Browse files
committed
Merge pull request reduxjs#373 from rwillrich/remove-es7-from-examples
Remove ES7 from examples
2 parents 3cfdd73 + 3dfbb1f commit 5e87896

File tree

11 files changed

+74
-60
lines changed

11 files changed

+74
-60
lines changed

examples/counter/.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"stage": 0
2+
"stage": 2
33
}
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import React, { Component, PropTypes } from 'react';
22

3-
export default class Counter extends Component {
4-
static propTypes = {
5-
increment: PropTypes.func.isRequired,
6-
incrementIfOdd: PropTypes.func.isRequired,
7-
decrement: PropTypes.func.isRequired,
8-
counter: PropTypes.number.isRequired
9-
};
10-
3+
class Counter extends Component {
114
render() {
125
const { increment, incrementIfOdd, decrement, counter } = this.props;
136
return (
@@ -23,3 +16,12 @@ export default class Counter extends Component {
2316
);
2417
}
2518
}
19+
20+
Counter.propTypes = {
21+
increment: PropTypes.func.isRequired,
22+
incrementIfOdd: PropTypes.func.isRequired,
23+
decrement: PropTypes.func.isRequired,
24+
counter: PropTypes.number.isRequired
25+
};
26+
27+
export default Counter;

examples/counter/containers/CounterApp.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { connect } from 'react-redux';
44
import Counter from '../components/Counter';
55
import * as CounterActions from '../actions/CounterActions';
66

7-
@connect(state => ({
8-
counter: state.counter
9-
}))
10-
export default class CounterApp extends Component {
7+
class CounterApp extends Component {
118
render() {
129
const { counter, dispatch } = this.props;
1310
return (
@@ -16,3 +13,7 @@ export default class CounterApp extends Component {
1613
);
1714
}
1815
}
16+
17+
export default connect(state => ({
18+
counter: state.counter
19+
}))(CounterApp);

examples/todomvc/.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"stage": 0
2+
"stage": 2
33
}

examples/todomvc/components/Footer.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ const FILTER_TITLES = {
88
[SHOW_MARKED]: 'Completed'
99
};
1010

11-
export default class Footer extends Component {
12-
static propTypes = {
13-
markedCount: PropTypes.number.isRequired,
14-
unmarkedCount: PropTypes.number.isRequired,
15-
filter: PropTypes.string.isRequired,
16-
onClearMarked: PropTypes.func.isRequired,
17-
onShow: PropTypes.func.isRequired
18-
}
19-
11+
class Footer extends Component {
2012
render() {
2113
return (
2214
<footer className='footer'>
@@ -69,3 +61,13 @@ export default class Footer extends Component {
6961
}
7062
}
7163
}
64+
65+
Footer.propTypes = {
66+
markedCount: PropTypes.number.isRequired,
67+
unmarkedCount: PropTypes.number.isRequired,
68+
filter: PropTypes.string.isRequired,
69+
onClearMarked: PropTypes.func.isRequired,
70+
onShow: PropTypes.func.isRequired
71+
};
72+
73+
export default Footer;

examples/todomvc/components/Header.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import React, { PropTypes, Component } from 'react';
22
import TodoTextInput from './TodoTextInput';
33

4-
export default class Header extends Component {
5-
static propTypes = {
6-
addTodo: PropTypes.func.isRequired
7-
};
8-
4+
class Header extends Component {
95
handleSave(text) {
106
if (text.length !== 0) {
117
this.props.addTodo(text);
@@ -17,9 +13,15 @@ export default class Header extends Component {
1713
<header className='header'>
1814
<h1>todos</h1>
1915
<TodoTextInput newTodo={true}
20-
onSave={::this.handleSave}
16+
onSave={this.handleSave.bind(this)}
2117
placeholder='What needs to be done?' />
2218
</header>
2319
);
2420
}
2521
}
22+
23+
Header.propTypes = {
24+
addTodo: PropTypes.func.isRequired
25+
};
26+
27+
export default Header;

examples/todomvc/components/MainSection.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ const TODO_FILTERS = {
99
[SHOW_MARKED]: todo => todo.marked
1010
};
1111

12-
export default class MainSection extends Component {
13-
static propTypes = {
14-
todos: PropTypes.array.isRequired,
15-
actions: PropTypes.object.isRequired
16-
};
17-
12+
class MainSection extends Component {
1813
constructor(props, context) {
1914
super(props, context);
2015
this.state = { filter: SHOW_ALL };
@@ -82,3 +77,10 @@ export default class MainSection extends Component {
8277
}
8378
}
8479
}
80+
81+
MainSection.propTypes = {
82+
todos: PropTypes.array.isRequired,
83+
actions: PropTypes.object.isRequired
84+
};
85+
86+
export default MainSection;

examples/todomvc/components/TodoItem.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@ import React, { Component, PropTypes } from 'react';
22
import classnames from 'classnames';
33
import TodoTextInput from './TodoTextInput';
44

5-
export default class TodoItem extends Component {
6-
static propTypes = {
7-
todo: PropTypes.object.isRequired,
8-
editTodo: PropTypes.func.isRequired,
9-
deleteTodo: PropTypes.func.isRequired,
10-
markTodo: PropTypes.func.isRequired
11-
};
12-
5+
class TodoItem extends Component {
136
constructor(props, context) {
147
super(props, context);
158
this.state = {
@@ -47,7 +40,7 @@ export default class TodoItem extends Component {
4740
type='checkbox'
4841
checked={todo.marked}
4942
onChange={() => markTodo(todo.id)} />
50-
<label onDoubleClick={::this.handleDoubleClick}>
43+
<label onDoubleClick={this.handleDoubleClick.bind(this)}>
5144
{todo.text}
5245
</label>
5346
<button className='destroy'
@@ -66,3 +59,12 @@ export default class TodoItem extends Component {
6659
);
6760
}
6861
}
62+
63+
TodoItem.propTypes = {
64+
todo: PropTypes.object.isRequired,
65+
editTodo: PropTypes.func.isRequired,
66+
deleteTodo: PropTypes.func.isRequired,
67+
markTodo: PropTypes.func.isRequired
68+
};
69+
70+
export default TodoItem;

examples/todomvc/components/TodoTextInput.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import React, { Component, PropTypes } from 'react';
22
import classnames from 'classnames';
33

4-
export default class TodoTextInput extends Component {
5-
static propTypes = {
6-
onSave: PropTypes.func.isRequired,
7-
text: PropTypes.string,
8-
placeholder: PropTypes.string,
9-
editing: PropTypes.bool,
10-
newTodo: PropTypes.bool
11-
};
12-
4+
class TodoTextInput extends Component {
135
constructor(props, context) {
146
super(props, context);
157
this.state = {
@@ -47,9 +39,19 @@ export default class TodoTextInput extends Component {
4739
placeholder={this.props.placeholder}
4840
autoFocus='true'
4941
value={this.state.text}
50-
onBlur={::this.handleBlur}
51-
onChange={::this.handleChange}
52-
onKeyDown={::this.handleSubmit} />
42+
onBlur={this.handleBlur.bind(this)}
43+
onChange={this.handleChange.bind(this)}
44+
onKeyDown={this.handleSubmit.bind(this)} />
5345
);
5446
}
5547
}
48+
49+
TodoTextInput.propTypes = {
50+
onSave: PropTypes.func.isRequired,
51+
text: PropTypes.string,
52+
placeholder: PropTypes.string,
53+
editing: PropTypes.bool,
54+
newTodo: PropTypes.bool
55+
};
56+
57+
export default TodoTextInput;

examples/todomvc/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'babel/polyfill';
2+
13
import React from 'react';
24
import App from './containers/App';
35
import 'todomvc-app-css/index.css';

examples/todomvc/reducers/todos.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,20 @@ export default function todos(state = initialState, action) {
2323
case EDIT_TODO:
2424
return state.map(todo =>
2525
todo.id === action.id ?
26-
{ ...todo, text: action.text } :
26+
Object.assign({}, todo, { text: action.text }) :
2727
todo
2828
);
2929

3030
case MARK_TODO:
3131
return state.map(todo =>
3232
todo.id === action.id ?
33-
{ ...todo, marked: !todo.marked } :
33+
Object.assign({}, todo, { marked: !todo.marked }) :
3434
todo
3535
);
3636

3737
case MARK_ALL:
3838
const areAllMarked = state.every(todo => todo.marked);
39-
return state.map(todo => ({
40-
...todo,
39+
return state.map(todo => Object.assign({}, todo, {
4140
marked: !areAllMarked
4241
}));
4342

0 commit comments

Comments
 (0)