react-router icon indicating copy to clipboard operation
react-router copied to clipboard

fix: support basename and relative routing in loader/action redirects

Open brophdawg11 opened this issue 2 years ago • 1 comments

Builds on top of original PR (#9418) to handle basename in loader/action redirects and also adds support for relative routing in redirects.

Basename example:

let router = createBrowserRouter([{
  path: '/',
  loader() {
    // This will now properly redirect the browser to /base/other
    return redirect('/other');
  },
}], { basename: '/base'}

Relative routing example:

let router = createBrowserRouter([{
  path: '/',
  children: [{
    path: 'parent',
    children: [{
      path: 'child',
      loader() {
        // This will now properly redirect the browser to /parent
        return redirect('..');
      },
    }],
  }]
}]);

Closes #9417

Co-authored-by: Mikaël ANZANO [email protected]

brophdawg11 avatar Oct 11 '22 20:10 brophdawg11

🦋 Changeset detected

Latest commit: d00e5bc3510b97413c81fdb263934ff02bd529e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@remix-run/router Patch
react-router Patch
react-router-dom Patch
react-router-dom-v5-compat Patch
react-router-native Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Oct 11 '22 20:10 changeset-bot[bot]

LGTM 👍

mjackson avatar Oct 20 '22 19:10 mjackson

Hi, it seems like useFetcher load method still does not respect basename.

cantti avatar Dec 08 '22 09:12 cantti

@cantti Can you open a new issue for that? 🙏🏼

machour avatar Dec 08 '22 11:12 machour

@machour sure, done.

cantti avatar Dec 09 '22 06:12 cantti