From 77ab7d2589f53082cca4873be97984253c2f27aa Mon Sep 17 00:00:00 2001 From: Pablo Saavedra Date: Mon, 23 Jul 2018 14:23:54 +0200 Subject: [PATCH] CreateRoomDialog is rendered before get default_federate value In React the order of the execution of mount and render functions is: `componentWillMount --> render --> componentDidMount` The `CreateRoomDialog` `render()` function is executed before than the `componentDidMount()` function so the `this.defaultNoFederate = config.default_federate === false;` ; instruction which is executed in the `componentDidMount` function (in `CreateRoomDialog`) is evaluated always after than the rendering of the page. Therefore, the obvious issue is that the values obtained from the `SdkConfig.get()` function (`config.default_federate`) are obtained later than their usage on `render()`. This patch makes this change to fix the described issue: * componentWillMount instead of componentDidMount Signed-off-by: Pablo Saavedra --- src/components/views/dialogs/CreateRoomDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/dialogs/CreateRoomDialog.js b/src/components/views/dialogs/CreateRoomDialog.js index 3b5369e8f6..3212e53c05 100644 --- a/src/components/views/dialogs/CreateRoomDialog.js +++ b/src/components/views/dialogs/CreateRoomDialog.js @@ -26,7 +26,7 @@ export default React.createClass({ onFinished: PropTypes.func.isRequired, }, - componentDidMount: function() { + componentWillMount: function() { const config = SdkConfig.get(); // Dialog shows inverse of m.federate (noFederate) strict false check to skip undefined check (default = true) this.defaultNoFederate = config.default_federate === false;