Reputation: 2551
the following is always returning an empty string on the button click
class Login extends Component {
constructor(props) {
super(props);
this.state = {
emailAddress: ""
};
}
loaddata = async () => {
let jiraURL = "";
let emailres = OTGWindowHelper.GetData();
let _settingsRes = OfficeClass.GetLocalData("user-credentials");
let userURLRes = Utils.getUserURL();
let [userURL, emailData, _settings] = await Promise.all([userURLRes, emailres, _settingsRes]);
.
.
.
//here i am setting the emailAddress
this.setState({emailAddress:emailData.EmailAddress})
// if i add console.log(this.state.emailAddress) i can clearly see the result
}
componentDidMount() {
this.loaddata();
}
validateURL = (event) => {
let userEmailAddress = this.state.emailAddress; // here is always empty
}
render (){
return (
<LoginFooter disabled={this.state.disableContinueButton} clicked={this.validateURL} />
)
}
Upvotes: 0
Views: 137
Reputation: 31
There can be a few reasons why this is happening:
if (emailData.EmailAddress) {
this.setState({emailAddress:emailData.EmailAddress})
}
Upvotes: 1