You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use useLoaderData to fetch my data and use it in the Component ComponentA, but there are some problems. ( createBrowserRouter + RouterProvider )
I have a link likes this: <a href="#hash">link</a>. And I click it many times and then ComponentA also re renders many times when the data from useLoaderData remains unchanged. The example is as follows.
Those links are causing a location change, so the router is triggered to re-match the current URL. This in turn causes the loader to re-run in case its output has changed. This is expected behavior for both React Router and React itself (a component's state changing, even to the same state, triggers a re-render).
What version of React Router are you using?
6.22.3
Steps to Reproduce
I use
useLoaderData
to fetch my data and use it in the ComponentComponentA
, but there are some problems. (createBrowserRouter
+RouterProvider
)I have a link likes this:
<a href="#hash">link</a>
. And I click it many times and thenComponentA
also re renders many times when the data fromuseLoaderData
remains unchanged. The example is as follows.see the example
Expected Behavior
ComponentA
should be unchanged when the url of page don't change. If possible, I expectComponentA
don't change when only hash changes.Actual Behavior
Actually,
ComponentA
re renders even if the url don't changeThe text was updated successfully, but these errors were encountered: