General react performance improvements (#2796)
* General React performance improvements * Cleaned up unused props/state in PermaLinkView and PostFocusView
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
9961ccca7d
Коммит
1f4974dc02
@@ -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
|
||||
};
|
||||
|
||||
Ссылка в новой задаче
Block a user