[Bug]: useHref updates result from useResolvedPath

1
closed
fxOne
fxOne
Posted 1 month ago

[Bug]: useHref updates result from useResolvedPath #8133

What version of React Router are you using?

v6.0.0-beta.6

Steps to Reproduce

I have the following sample:

return <Router basename="/_basePath">
  //...
  <Link to="/page1"/>
  //... 
</Router>;

Expected Behavior

I expected the following output:

<a href="/_basePath/page1"></a>

Actual Behavior

In some cases I get the following result as the Link component is rendered multiple times:

<a href="/_basePath/_basePath/_basePath/page1"></a>

The issue is that useHref is overwriting the reference which is returned from useResolvedPath and prepend the basepath multiple times: https://github.com/remix-run/react-router/blob/f41e3c95eb848b292244e1e1cb1eb2a6cc3f7525/packages/react-router/index.tsx#L402

fxOne
fxOne
Created 1 month ago

Thanks for fix in v6.0.0-beta.8