From e139f5212a98be8e2a318da12e75c32042f10af9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 29 Mar 2017 15:05:49 +0100 Subject: [PATCH] Remove React warning Fire onOptionChange in componentWillMount, otherwise end up trying to update state effectively in a render method, which is bad. --- src/components/views/login/CountryDropdown.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/views/login/CountryDropdown.js b/src/components/views/login/CountryDropdown.js index fc1e89661b..9729c9e23f 100644 --- a/src/components/views/login/CountryDropdown.js +++ b/src/components/views/login/CountryDropdown.js @@ -43,8 +43,10 @@ export default class CountryDropdown extends React.Component { this.state = { searchQuery: '', } + } - if (!props.value) { + componentWillMount() { + if (!this.props.value) { // If no value is given, we start with the first // country selected, but our parent component // doesn't know this, therefore we do this.