File tree Expand file tree Collapse file tree 11 files changed +29
-54
lines changed Expand file tree Collapse file tree 11 files changed +29
-54
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import PureRenderMixin from 'react-addons-pure-render-mixin' ;
3
+
4
+ export default class BaseComponent extends React . Component {
5
+ shouldComponentUpdate ( ) {
6
+ return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
7
+ }
8
+ }
Original file line number Diff line number Diff line change 1
1
import React , { PropTypes } from 'react' ;
2
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
3
2
4
3
import CommentForm from './CommentForm/CommentForm' ;
5
4
import CommentList from './CommentList/CommentList' ;
6
5
import css from './CommentBox.scss' ;
6
+ import BaseComponent from '../BaseComponent' ;
7
7
8
- export default class CommentBox extends React . Component {
8
+ export default class CommentBox extends BaseComponent {
9
9
static propTypes = {
10
10
pollInterval : PropTypes . number . isRequired ,
11
11
actions : PropTypes . object . isRequired ,
12
12
data : PropTypes . object . isRequired ,
13
13
} ;
14
14
15
- shouldComponentUpdate ( ) {
16
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
17
- }
18
-
19
15
componentDidMount ( ) {
20
16
const { fetchComments } = this . props . actions ;
21
17
fetchComments ( ) ;
Original file line number Diff line number Diff line change @@ -8,12 +8,13 @@ import NavItem from 'react-bootstrap/lib/NavItem';
8
8
import Alert from 'react-bootstrap/lib/Alert' ;
9
9
import ReactCSSTransitionGroup from 'react/lib/ReactCSSTransitionGroup' ;
10
10
import _ from 'lodash' ;
11
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
11
+
12
+ import BaseComponent from '../../BaseComponent' ;
12
13
13
14
const emptyComment = { author : '' , text : '' } ;
14
15
const textPlaceholder = 'Say something using markdown...' ;
15
16
16
- export default class CommentForm extends React . Component {
17
+ export default class CommentForm extends BaseComponent {
17
18
static propTypes = {
18
19
isSaving : PropTypes . bool . isRequired ,
19
20
actions : PropTypes . object . isRequired ,
@@ -36,10 +37,6 @@ export default class CommentForm extends React.Component {
36
37
] ) ;
37
38
}
38
39
39
- shouldComponentUpdate ( ) {
40
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
41
- }
42
-
43
40
_handleSelect ( selectedKey ) {
44
41
this . setState ( { formMode : selectedKey } ) ;
45
42
}
Original file line number Diff line number Diff line change 1
1
import React , { PropTypes } from 'react' ;
2
2
import marked from 'marked' ;
3
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
4
3
5
4
import css from './Comment.scss' ;
5
+ import BaseComponent from '../../../BaseComponent' ;
6
6
7
- export default class Comment extends React . Component {
7
+ export default class Comment extends BaseComponent {
8
8
static propTypes = {
9
9
author : PropTypes . string . isRequired ,
10
10
text : PropTypes . string . isRequired ,
11
11
} ;
12
12
13
- shouldComponentUpdate ( ) {
14
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
15
- }
16
-
17
13
render ( ) {
18
14
const { author, text } = this . props ;
19
15
const rawMarkup = marked ( text , { gfm : true , sanitize : true } ) ;
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ import Immutable from 'immutable';
3
3
import Alert from 'react-bootstrap/lib/Alert' ;
4
4
import ReactCSSTransitionGroup from 'react/lib/ReactCSSTransitionGroup' ;
5
5
import _ from 'lodash' ;
6
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
7
6
8
7
import Comment from './Comment/Comment' ;
8
+ import BaseComponent from '../../BaseComponent' ;
9
9
10
- export default class CommentList extends React . Component {
10
+ export default class CommentList extends BaseComponent {
11
11
static propTypes = {
12
12
$$comments : PropTypes . instanceOf ( Immutable . List ) . isRequired ,
13
13
error : PropTypes . any ,
@@ -20,10 +20,6 @@ export default class CommentList extends React.Component {
20
20
_ . bindAll ( this , '_errorWarning' ) ;
21
21
}
22
22
23
- shouldComponentUpdate ( ) {
24
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
25
- }
26
-
27
23
_errorWarning ( ) {
28
24
// If there is no error, there is nothing to add to the DOM
29
25
if ( ! this . props . error ) return null ;
Original file line number Diff line number Diff line change 1
1
import React , { PropTypes } from 'react' ;
2
2
3
3
import CommentBox from '../CommentBox/CommentBox' ;
4
-
5
4
import css from './CommentScreen.scss' ;
5
+ import BaseComponent from '../BaseComponent' ;
6
6
7
- export default class CommentScreen extends React . Component {
7
+ export default class CommentScreen extends BaseComponent {
8
8
9
9
static propTypes = {
10
10
actions : PropTypes . object . isRequired ,
Original file line number Diff line number Diff line change @@ -2,14 +2,14 @@ import React from 'react';
2
2
import Immutable from 'immutable' ;
3
3
import request from 'axios' ;
4
4
import _ from 'lodash' ;
5
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
6
5
7
6
import metaTagsManager from 'libs/metaTagsManager' ;
8
7
import CommentForm from '../CommentBox/CommentForm/CommentForm' ;
9
8
import CommentList from '../CommentBox/CommentList/CommentList' ;
10
9
import css from './SimpleCommentScreen.scss' ;
10
+ import BaseComponent from '../BaseComponent' ;
11
11
12
- export default class SimpleCommentScreen extends React . Component {
12
+ export default class SimpleCommentScreen extends BaseComponent {
13
13
constructor ( props , context ) {
14
14
super ( props , context ) ;
15
15
this . state = {
@@ -22,10 +22,6 @@ export default class SimpleCommentScreen extends React.Component {
22
22
_ . bindAll ( this , '_fetchComments' , '_handleCommentSubmit' ) ;
23
23
}
24
24
25
- shouldComponentUpdate ( ) {
26
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
27
- }
28
-
29
25
componentDidMount ( ) {
30
26
this . _fetchComments ( ) ;
31
27
}
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
3
2
4
- export default class TestReactRouter extends React . Component {
5
- shouldComponentUpdate ( ) {
6
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
7
- }
3
+ import BaseComponent from '../BaseComponent' ;
8
4
5
+ export default class TestReactRouter extends BaseComponent {
9
6
render ( ) {
10
7
return (
11
8
< div className = "container" >
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
3
2
4
- export default class TestReactRouterRedirect extends React . Component {
5
- shouldComponentUpdate ( ) {
6
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
7
- }
3
+ import BaseComponent from '../BaseComponent' ;
8
4
5
+ export default class TestReactRouterRedirect extends BaseComponent {
9
6
static checkAuth ( nextState , replaceState ) {
10
7
// Hard code this to demonstrate the effect
11
8
const notAuthorized = true ;
Original file line number Diff line number Diff line change 1
1
import React , { PropTypes } from 'react' ;
2
2
import { connect } from 'react-redux' ;
3
3
import { bindActionCreators } from 'redux' ;
4
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
5
4
6
5
import CommentScreen from '../components/CommentScreen/CommentScreen' ;
7
6
import * as commentsActionCreators from '../actions/commentsActionCreators' ;
7
+ import BaseComponent from '../components/BaseComponent' ;
8
8
9
9
function select ( state ) {
10
10
// Which part of the Redux global state does our component want to receive as props?
11
11
return { data : state . $$commentsStore } ;
12
12
}
13
13
14
- class NonRouterCommentsContainer extends React . Component {
14
+ class NonRouterCommentsContainer extends BaseComponent {
15
15
static propTypes = {
16
16
dispatch : PropTypes . func . isRequired ,
17
17
data : PropTypes . object . isRequired ,
18
18
} ;
19
19
20
- shouldComponentUpdate ( ) {
21
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
22
- }
23
-
24
20
render ( ) {
25
21
const { dispatch, data } = this . props ;
26
22
const actions = bindActionCreators ( commentsActionCreators , dispatch ) ;
Original file line number Diff line number Diff line change 1
1
import React , { PropTypes } from 'react' ;
2
2
import { connect } from 'react-redux' ;
3
3
import { bindActionCreators } from 'redux' ;
4
- import PureRenderMixin from 'react-addons-pure-render-mixin' ;
5
4
6
5
import CommentScreen from '../components/CommentScreen/CommentScreen' ;
7
6
import * as commentsActionCreators from '../actions/commentsActionCreators' ;
7
+ import BaseComponent from '../components/BaseComponent' ;
8
8
9
9
function select ( state ) {
10
10
// Which part of the Redux global state does our component want to receive as props?
11
11
return { data : state . $$commentsStore } ;
12
12
}
13
13
14
- class RouterCommentsContainer extends React . Component {
14
+ class RouterCommentsContainer extends BaseComponent {
15
15
static propTypes = {
16
16
dispatch : PropTypes . func . isRequired ,
17
17
data : PropTypes . object . isRequired ,
@@ -20,10 +20,6 @@ class RouterCommentsContainer extends React.Component {
20
20
} ) . isRequired ,
21
21
} ;
22
22
23
- shouldComponentUpdate ( ) {
24
- return PureRenderMixin . shouldComponentUpdate . apply ( this , arguments ) ;
25
- }
26
-
27
23
render ( ) {
28
24
const { dispatch, data } = this . props ;
29
25
const actions = bindActionCreators ( commentsActionCreators , dispatch ) ;
You can’t perform that action at this time.
0 commit comments