summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-01-21 07:08:31 -0500
committerJoram Wilander <jwawilander@gmail.com>2016-01-21 07:08:31 -0500
commit45457a9d59657baa5c58d4c34de1cf7a144b77ab (patch)
treece21bd88781d13803bbd5eff0e478c2bcc1353c9
parent202e00d8dffc806a9a5686d784c2bbfd76494649 (diff)
parent24f422dde3678871b65112b45b8df0cf8f1e22fb (diff)
downloadchat-45457a9d59657baa5c58d4c34de1cf7a144b77ab.tar.gz
chat-45457a9d59657baa5c58d4c34de1cf7a144b77ab.tar.bz2
chat-45457a9d59657baa5c58d4c34de1cf7a144b77ab.zip
Merge pull request #1886 from rgarmsen2295/plt-549c
PLT-549 Fixed react warning issue with setState in RHS
-rw-r--r--web/react/components/rhs_thread.jsx12
1 files changed, 10 insertions, 2 deletions
diff --git a/web/react/components/rhs_thread.jsx b/web/react/components/rhs_thread.jsx
index 2edcd8b37..945b09e37 100644
--- a/web/react/components/rhs_thread.jsx
+++ b/web/react/components/rhs_thread.jsx
@@ -17,6 +17,8 @@ export default class RhsThread extends React.Component {
constructor(props) {
super(props);
+ this.mounted = false;
+
this.onChange = this.onChange.bind(this);
this.onChangeAll = this.onChangeAll.bind(this);
this.forceUpdateInfo = this.forceUpdateInfo.bind(this);
@@ -50,8 +52,11 @@ export default class RhsThread extends React.Component {
PostStore.addSelectedPostChangeListener(this.onChange);
PostStore.addChangeListener(this.onChangeAll);
PreferenceStore.addChangeListener(this.forceUpdateInfo);
+
this.resize();
window.addEventListener('resize', this.handleResize);
+
+ this.mounted = true;
}
componentDidUpdate() {
if ($('.post-right__scroll')[0]) {
@@ -63,7 +68,10 @@ export default class RhsThread extends React.Component {
PostStore.removeSelectedPostChangeListener(this.onChange);
PostStore.removeChangeListener(this.onChangeAll);
PreferenceStore.removeChangeListener(this.forceUpdateInfo);
+
window.removeEventListener('resize', this.handleResize);
+
+ this.mounted = false;
}
forceUpdateInfo() {
if (this.state.postList) {
@@ -82,7 +90,7 @@ export default class RhsThread extends React.Component {
}
onChange() {
var newState = this.getStateFromStores();
- if (!Utils.areObjectsEqual(newState, this.state)) {
+ if (this.mounted && !Utils.areObjectsEqual(newState, this.state)) {
this.setState(newState);
}
}
@@ -120,7 +128,7 @@ export default class RhsThread extends React.Component {
}
var newState = this.getStateFromStores();
- if (!Utils.areObjectsEqual(newState, this.state)) {
+ if (this.mounted && !Utils.areObjectsEqual(newState, this.state)) {
this.setState(newState);
}
}