Closed douglasrcjames closed 3 years ago
Can you create a minimal reproduction on https://codesandbox.io?
Thanks for the reproduction. I think your error is in your routes and not related to react-router-hash-link
. When you do <Route exact path="/" component={() => <Home />} />
, in particular () => <Home />
, it will create a new instance of Home
on every render. Instead usecomponent={Home}
, or use a render
prop if you need to write jsx to pass in additional props to Home
. Here is it working: https://codesandbox.io/s/hero-page-with-anchor-forked-ysoem?file=/src/routes.js:326-378
Thanks so much @rafgraph for educating me on this, I am good to go now!
I am trying to scroll down to an element on a page without losing the information in the current component state, but I can't seem to get it working. I have looked around all over the web and am getting the vibe that this may not be possible with React at all? Which seems like a short sight and maybe I am not looking in the right place. Has anyone had this issue? If so can someone help me solve it?