Skip to content

Commit e78dbda

Browse files
committed
Using mixin instead of decorator
1 parent 3c541ae commit e78dbda

File tree

10 files changed

+44
-17
lines changed

10 files changed

+44
-17
lines changed

client/app/bundles/comments/components/CommentBox/CommentBox.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { PropTypes } from 'react';
2-
import pureRender from 'pure-render-decorator';
2+
import PureRenderMixin from 'react-addons-pure-render-mixin';
33

44
import CommentForm from './CommentForm/CommentForm';
55
import CommentList from './CommentList/CommentList';
@@ -12,6 +12,10 @@ export default class CommentBox extends React.Component {
1212
data: PropTypes.object.isRequired,
1313
};
1414

15+
shouldComponentUpdate() {
16+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
17+
}
18+
1519
componentDidMount() {
1620
const { fetchComments } = this.props.actions;
1721
fetchComments();

client/app/bundles/comments/components/CommentBox/CommentForm/CommentForm.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import NavItem from 'react-bootstrap/lib/NavItem';
88
import Alert from 'react-bootstrap/lib/Alert';
99
import ReactCSSTransitionGroup from 'react/lib/ReactCSSTransitionGroup';
1010
import _ from 'lodash';
11-
import pureRender from 'pure-render-decorator';
11+
import PureRenderMixin from 'react-addons-pure-render-mixin';
1212

1313
const emptyComment = { author: '', text: '' };
1414
const textPlaceholder = 'Say something using markdown...';
@@ -36,6 +36,10 @@ export default class CommentForm extends React.Component {
3636
]);
3737
}
3838

39+
shouldComponentUpdate() {
40+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
41+
}
42+
3943
_handleSelect(selectedKey) {
4044
this.setState({ formMode: selectedKey });
4145
}

client/app/bundles/comments/components/CommentBox/CommentList/Comment/Comment.jsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
import React, { PropTypes } from 'react';
22
import marked from 'marked';
3-
import pureRender from 'pure-render-decorator';
3+
import PureRenderMixin from 'react-addons-pure-render-mixin';
44

5-
<<<<<<< HEAD:client/app/bundles/comments/components/CommentBox/CommentList/Comment/Comment.jsx
65
import css from './Comment.scss';
76

87
export default class Comment extends React.Component {
9-
10-
=======
11-
@pureRender
12-
class Comment extends React.Component {
13-
static displayName = 'Comment';
14-
>>>>>>> Including pure render decorator:client/app/bundles/Comments/components/Comment.jsx
158
static propTypes = {
169
author: PropTypes.string.isRequired,
1710
text: PropTypes.string.isRequired,
1811
};
1912

13+
shouldComponentUpdate() {
14+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
15+
}
16+
2017
render() {
2118
const { author, text } = this.props;
2219
const rawMarkup = marked(text, { gfm: true, sanitize: true });

client/app/bundles/comments/components/CommentBox/CommentList/CommentList.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Immutable from 'immutable';
33
import Alert from 'react-bootstrap/lib/Alert';
44
import ReactCSSTransitionGroup from 'react/lib/ReactCSSTransitionGroup';
55
import _ from 'lodash';
6+
import PureRenderMixin from 'react-addons-pure-render-mixin';
67

78
import Comment from './Comment/Comment';
89

@@ -19,6 +20,10 @@ export default class CommentList extends React.Component {
1920
_.bindAll(this, '_errorWarning');
2021
}
2122

23+
shouldComponentUpdate() {
24+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
25+
}
26+
2227
_errorWarning() {
2328
// If there is no error, there is nothing to add to the DOM
2429
if (!this.props.error) return null;

client/app/bundles/comments/components/SimpleCommentScreen/SimpleCommentScreen.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import Immutable from 'immutable';
33
import request from 'axios';
44
import _ from 'lodash';
5+
import PureRenderMixin from 'react-addons-pure-render-mixin';
56

67
import metaTagsManager from 'libs/metaTagsManager';
78
import CommentForm from '../CommentBox/CommentForm/CommentForm';
@@ -20,6 +21,10 @@ export default class SimpleCommentScreen extends React.Component {
2021
_.bindAll(this, '_fetchComments', '_handleCommentSubmit');
2122
}
2223

24+
shouldComponentUpdate() {
25+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
26+
}
27+
2328
componentDidMount() {
2429
this._fetchComments();
2530
}

client/app/bundles/comments/components/TestReactRouter/TestReactRouter.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from 'react';
2-
import pureRender from 'pure-render-decorator';
2+
import PureRenderMixin from 'react-addons-pure-render-mixin';
33

4-
@pureRender
54
export default class TestReactRouter extends React.Component {
5+
shouldComponentUpdate() {
6+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
7+
}
68

79
render() {
810
return (

client/app/bundles/comments/components/TestReactRouterRedirect/TestReactRouterRedirect.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from 'react';
2-
import pureRender from 'pure-render-decorator';
2+
import PureRenderMixin from 'react-addons-pure-render-mixin';
33

4-
@pureRender
54
export default class TestReactRouterRedirect extends React.Component {
5+
shouldComponentUpdate() {
6+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
7+
}
68

79
static checkAuth(nextState, replaceState) {
810
// Hard code this to demonstrate the effect

client/app/bundles/comments/containers/NonRouterCommentsContainer.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PropTypes } from 'react';
22
import { connect } from 'react-redux';
33
import { bindActionCreators } from 'redux';
4-
import pureRender from 'pure-render-decorator';
4+
import PureRenderMixin from 'react-addons-pure-render-mixin';
55

66
import CommentScreen from '../components/CommentScreen/CommentScreen';
77
import * as commentsActionCreators from '../actions/commentsActionCreators';
@@ -17,6 +17,10 @@ class NonRouterCommentsContainer extends React.Component {
1717
data: PropTypes.object.isRequired,
1818
};
1919

20+
shouldComponentUpdate() {
21+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
22+
}
23+
2024
render() {
2125
const { dispatch, data } = this.props;
2226
const actions = bindActionCreators(commentsActionCreators, dispatch);

client/app/bundles/comments/containers/RouterCommentsContainer.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PropTypes } from 'react';
22
import { connect } from 'react-redux';
33
import { bindActionCreators } from 'redux';
4-
import pureRender from 'pure-render-decorator';
4+
import PureRenderMixin from 'react-addons-pure-render-mixin';
55

66
import CommentScreen from '../components/CommentScreen/CommentScreen';
77
import * as commentsActionCreators from '../actions/commentsActionCreators';
@@ -20,6 +20,10 @@ class RouterCommentsContainer extends React.Component {
2020
}).isRequired,
2121
};
2222

23+
shouldComponentUpdate() {
24+
return PureRenderMixin.shouldComponentUpdate.apply(this, arguments);
25+
}
26+
2327
render() {
2428
const { dispatch, data } = this.props;
2529
const actions = bindActionCreators(commentsActionCreators, dispatch);

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"node-uuid": "^1.4.7",
6868
"postcss-loader": "^0.8.0",
6969
"react": "^0.14.3",
70-
"react-addons-shallow-compare": "^0.14.3",
70+
"react-addons-pure-render-mixin": "^0.14.3",
7171
"react-bootstrap": "^0.28.1",
7272
"react-dom": "^0.14.3",
7373
"react-redux": "^4.0.0",

0 commit comments

Comments
 (0)