General react performance improvements (#2796)

* General React performance improvements

* Cleaned up unused props/state in PermaLinkView and PostFocusView
Этот коммит содержится в:
Joram Wilander
2016-04-29 08:40:06 -04:00
коммит произвёл Christopher Speller
родитель 9961ccca7d
Коммит 1f4974dc02
19 изменённых файлов: 255 добавлений и 227 удалений

Просмотреть файл

@@ -11,6 +11,8 @@ import PostsViewContainer from 'components/posts_view_container.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import * as Utils from 'utils/utils.jsx';
export default class ChannelView extends React.Component {
constructor(props) {
super(props);
@@ -47,6 +49,17 @@ export default class ChannelView extends React.Component {
componentWillReceiveProps(nextProps) {
this.setState(this.getStateFromStores(nextProps));
}
shouldComponentUpdate(nextProps, nextState) {
if (!Utils.areObjectsEqual(nextProps.params, this.props.params)) {
return true;
}
if (nextState.channelId !== this.state.channelId) {
return true;
}
return false;
}
render() {
return (
<div
@@ -57,7 +70,7 @@ export default class ChannelView extends React.Component {
<ChannelHeader
channelId={this.state.channelId}
/>
<PostsViewContainer profiles={this.props.profiles}/>
<PostsViewContainer/>
<div
className='post-create__container'
id='post-create'
@@ -72,6 +85,5 @@ ChannelView.defaultProps = {
};
ChannelView.propTypes = {
params: React.PropTypes.object.isRequired,
profiles: React.PropTypes.object
params: React.PropTypes.object.isRequired
};