Set rooms event listeners during the correct life cycle hook
This commit is contained in:
parent
36e729a626
commit
a59873df0b
3 changed files with 36 additions and 27 deletions
|
@ -125,8 +125,6 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
|||
};
|
||||
// Why Object.assign() and not this.state.height? Because TypeScript says no.
|
||||
this.state = Object.assign(this.state, {height: this.calculateInitialHeight()});
|
||||
this.dispatcherRef = defaultDispatcher.register(this.onAction);
|
||||
RoomListStore.instance.on(LISTS_UPDATE_EVENT, this.onListsUpdated);
|
||||
}
|
||||
|
||||
private calculateInitialHeight() {
|
||||
|
@ -242,6 +240,11 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
|||
return false;
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
this.dispatcherRef = defaultDispatcher.register(this.onAction);
|
||||
RoomListStore.instance.on(LISTS_UPDATE_EVENT, this.onListsUpdated);
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
defaultDispatcher.unregister(this.dispatcherRef);
|
||||
RoomListStore.instance.off(LISTS_UPDATE_EVENT, this.onListsUpdated);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue