I have a text which was earlier wrapped in an H1 tag. I need to focus on that text once my page is loaded. I wrapped it in a div for my convenience.
render() {
const { translate, billing: { primaryContactSelection = true } } = this.props;
return (
<div {...resolve(BillingStyles, 'billingContainer')}>
<div id="mainHeader"><h1 {...resolve(BillingStyles, 'mainHeader')}>
{translate('PanelBillingHeadingText')}
</h1> </div>
<div {...resolve(BillingStyles, 'billingInfoContainer')}>
......
......
</div>
</div>
);
}
}
I have tried the below code:
componentDidMount() {
console.log('Component Did Mount .............');
document.getElementById('#mainHeader').focus();
}
But it is not focusing on the div.