Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: useFetcher load method does not respect basename #9711

Closed
cantti opened this issue Dec 9, 2022 · 7 comments · Fixed by #10336
Closed

[Bug]: useFetcher load method does not respect basename #9711

cantti opened this issue Dec 9, 2022 · 7 comments · Fixed by #10336
Labels

Comments

@cantti
Copy link

cantti commented Dec 9, 2022

What version of React Router are you using?

6.4.5

Steps to Reproduce

Create an app like this

import ReactDOM from "react-dom/client";
import {
  createBrowserRouter,
  RouterProvider,
  useFetcher,
} from "react-router-dom";

const router = createBrowserRouter(
  [
    {
      path: "/",
      element: <App />,
    },
    {
      path: "/load",
      loader: () => {
        console.log("load");
        return null;
      },
    },
  ],
  { basename: "/base" }
);

function App() {
  const fetcher = useFetcher();
  return (
    <button type="button" onClick={() => fetcher.load("/load")}>
      Click Me!
    </button>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(
  <RouterProvider router={router} />
);

Expected Behavior

No errors, "load" in console.

Actual Behavior

Browser displays message to user:

Unhandled Thrown Error!
404 Not Found

@brophdawg11
Copy link
Contributor

We plan to get this added - right now fetchers don't support relative routing or basename (a bit of an oversight), but we are going to do it as part of a larger initiative to move all relative (and basename) routing logic into the @remix-run/router and out of the component-layer. You can follow along (and upvote!) in this proposal: #9588

@brophdawg11
Copy link
Contributor

This is handled in #10336 and should be available in the next release

@brophdawg11 brophdawg11 added the awaiting release This issue have been fixed and will be released soon label Apr 14, 2023
@brophdawg11
Copy link
Contributor

Reopening until this is released to npm

@brophdawg11 brophdawg11 reopened this Apr 17, 2023
@brophdawg11
Copy link
Contributor

Aligning with Remix here - will close this issue with awaiting release. This will be available once React Router 6.11 is released.

@brophdawg11 brophdawg11 removed their assignment Apr 21, 2023
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 6.11.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 6.11.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue have been fixed and will be released soon label Apr 28, 2023
@brophdawg11
Copy link
Contributor

@sarahdrs Can you provide a reproduction? This seems to be working in a simple example (ensure you add /base to the sandbox window URL): https://codesandbox.io/s/weathered-dew-9uuo14?file=/src/index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants