From caddea67582fe0b3094a70d1518ba53e23416d8a Mon Sep 17 00:00:00 2001 From: Olivia Ruiz-Knott Date: Tue, 30 Jun 2020 16:02:54 -0400 Subject: [PATCH] Consider this for alert reference? --- .../demographics/DemographicsSection.jsx | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/account-settings/demographics/DemographicsSection.jsx b/src/account-settings/demographics/DemographicsSection.jsx index 911b3d3..06e750d 100644 --- a/src/account-settings/demographics/DemographicsSection.jsx +++ b/src/account-settings/demographics/DemographicsSection.jsx @@ -33,21 +33,12 @@ import messages from './DemographicsSection.messages'; class DemographicsSection extends React.Component { constructor(props, context) { super(props, context); - - this.alert = null; - - this.setAlertRef = element => { - this.alert = element; - } - - this.focusAlert = () => { - if (this.alert) this.alert.focus(); - } + this.alertRef = React.createRef(); } componentDidUpdate() { if(!isEmpty(this.props.formErrors)) { - this.focusAlert(); + this.alertRef.current.focus(); } } @@ -125,12 +116,12 @@ class DemographicsSection extends React.Component { * display an Alert letting the user know that their info will not be retrieved or displayed * and temporarily cannot be updated. */ - renderDemographicsServiceIssueWarning() { + renderDemographicsServiceIssueWarning() { if (!isEmpty(this.props.formErrors)) { return ( -
+ ref={this.alertRef}>