In React, how to extract a tag id from URL and then manually scroll to it?

My app design is a bit non traditional, where there are a bunch of listeners for each page that listen to the URL and then hides or shows a page.

It doesn’t appear to be working well with linking to pages that then scroll to a element by id.

How can the #element-id bit be manually extracted from the URl and then manually scroll to the element?