Auto scroll to anchor tag element in react using componentDidUpdate
问题 My URL https://abc1234.com/users#api-doc HTML <div className={parent}> <div className={child}> {someContent} <a id="api-doc">Hello API</a> </div> </div> I am writing the page in ReactJS. I need to implement a way so that the page should auto-scroll down to the Hash i.e. api-doc but somehow it's not auto-scrolling on page load (very first time). I tried a workaround which is like this componentDidUpdate(){ let id = this.props.history.location.hash.replace("#", ""); let element = document