Navigate then perform action
This function is an event handler for a bunch of buttons. It's prop(para) is different for each button.
It navigates to a different url. Each URL it navigates to loads the same components with different data based on the params, which change each time the button is pressed. When that component loads it sets an array from a provider with 100s of refs.
After the new URL has been navigated to and the refs have loaded I would very much like to .scrollIntoView() to that ref. SO I set a timeOut around all of that....to make sure the component has loaded and the refs are all in the provider.
Problem: Which ever button I click first, it works. Sometimes the second click works. But more often than not the scrollIntoView stops works after the second or third button click. The navigate always works(it always goes to the new url).
No error messages. I am console logging matchingRef and it's always right. Not sure why scrollIntoView stops working eventually. Not sure if there's just a better way to do this
It navigates to a different url. Each URL it navigates to loads the same components with different data based on the params, which change each time the button is pressed. When that component loads it sets an array from a provider with 100s of refs.
After the new URL has been navigated to and the refs have loaded I would very much like to .scrollIntoView() to that ref. SO I set a timeOut around all of that....to make sure the component has loaded and the refs are all in the provider.
Problem: Which ever button I click first, it works. Sometimes the second click works. But more often than not the scrollIntoView stops works after the second or third button click. The navigate always works(it always goes to the new url).
No error messages. I am console logging matchingRef and it's always right. Not sure why scrollIntoView stops working eventually. Not sure if there's just a better way to do this
