This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
CreateRoomDialog is rendered before getting the config default_federate #2078
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CreateRoomDialog is rendered before get the config default_federate value
In React the order of the execution of mount and render functions is:
componentWillMount --> render --> componentDidMount
(Ref: https://stackoverflow.com/questions/45337165/react-render-is-being-called-before-componentdidmount and https://developmentarc.gitbooks.io/react-indepth/content/life_cycle/birth/premounting_with_componentwillmount.html )
The
CreateRoomDialog
render()
function is executed before than thecomponentDidMount()
function so the; instruction which is executed in the
componentDidMount
function (inCreateRoomDialog
) 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 onrender()
.On other hand, if the
render()
method depends on some other data a part of props, you need tell React that the component needs re-rendering by calling setState(). This is need to say React that the status of the checkbox was toggled.(Ref: https://reactjs.org/docs/react-component.html#setstate)
This patch made those changes to fix the described issues:
Signed-off-by: Pablo Saavedra [email protected]