From 1f4974dc02c786b65c802d4497fd736cca79d01c Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 29 Apr 2016 08:40:06 -0400 Subject: General react performance improvements (#2796) * General React performance improvements * Cleaned up unused props/state in PermaLinkView and PostFocusView --- webapp/components/channel_info_modal.jsx | 13 +++- webapp/components/channel_view.jsx | 18 ++++- webapp/components/floating_timestamp.jsx | 54 +++++++++++++ webapp/components/get_post_link_modal.jsx | 33 ++------ webapp/components/get_team_invite_link_modal.jsx | 41 +++------- webapp/components/more_channels.jsx | 17 ++-- webapp/components/more_direct_channels.jsx | 21 ++++- webapp/components/needs_team.jsx | 7 +- webapp/components/permalink_view.jsx | 8 +- webapp/components/post_body.jsx | 47 +++++++----- webapp/components/post_focus_view.jsx | 21 +---- webapp/components/posts_view.jsx | 98 ++++++++++-------------- webapp/components/posts_view_container.jsx | 22 ++---- webapp/components/rhs_comment.jsx | 39 ++++------ webapp/components/sidebar.jsx | 5 -- webapp/components/sidebar_right_menu.jsx | 3 + webapp/components/time_since.jsx | 6 ++ webapp/components/user_profile.jsx | 19 +++++ webapp/package.json | 6 +- 19 files changed, 253 insertions(+), 225 deletions(-) create mode 100644 webapp/components/floating_timestamp.jsx (limited to 'webapp') diff --git a/webapp/components/channel_info_modal.jsx b/webapp/components/channel_info_modal.jsx index 4c16dda90..d44df4056 100644 --- a/webapp/components/channel_info_modal.jsx +++ b/webapp/components/channel_info_modal.jsx @@ -9,6 +9,17 @@ import {Modal} from 'react-bootstrap'; import React from 'react'; export default class ChannelInfoModal extends React.Component { + shouldComponentUpdate(nextProps) { + if (nextProps.show !== this.props.show) { + return true; + } + + if (!Utils.areObjectsEqual(nextProps.channel, this.props.channel)) { + return true; + } + + return false; + } render() { let channel = this.props.channel; if (!channel) { @@ -93,4 +104,4 @@ ChannelInfoModal.propTypes = { show: React.PropTypes.bool.isRequired, onHide: React.PropTypes.func.isRequired, channel: React.PropTypes.object.isRequired -}; \ No newline at end of file +}; diff --git a/webapp/components/channel_view.jsx b/webapp/components/channel_view.jsx index 45d0f2393..6511d960a 100644 --- a/webapp/components/channel_view.jsx +++ b/webapp/components/channel_view.jsx @@ -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 (
- +
; + } + + if (this.props.createAt === 0) { + return