fix: memoize matches provider data
The MatchesProvider value changes on every render every time the provider is rendered. This causes any component using the useMatch or useMatches hook to re-render 3 times when navigating. Two of these renders occur before the routes update.
I am using the useMatch hook to access route loader data on my pages, and they currently re-render twice before unmounting because of a route change.
This PR fixes this by performing a shallow compare on the RouteMatch array and returning the old value if they are equal.
@rstrand is attempting to deploy a commit to the Tanstack Team on Vercel.
A member of the Team first needs to authorize it.
I would love to see this change accepted. We've been bitten by the double re-render before the route is updated several times.
This will need to be reworked for TanStack Router