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

Possibility to flatten nested routes #471

Open
SimonChaumet opened this issue May 20, 2021 · 1 comment
Open

Possibility to flatten nested routes #471

SimonChaumet opened this issue May 20, 2021 · 1 comment

Comments

@SimonChaumet
Copy link

Feature Request

It would be really nice to have a way to flatten the routes of the components.

Example

In my application I have public routes and private routes, so I created a component Public which has a router, and my public routes inside, and I have an equivalent for private routes. I want each of them to be at /*, but doing so make the library only choose the first one.
The Public and Private components are just for organization.

E.g :

const Public: React.FC<RouteComponentProps> = () => {
  return (
    <Router>
      <Redirect from={"/"} to={"/login"} noThrow />
      <Login path={"/login"} />
    </Router>
  );
};

const Private: React.FC<RouteComponentProps> = () => {
  return (
    <Router>
      <Profile path={"/profile"} />
    </Router>
  );
};

const App: React.FC = () => {
  return (
    <Router>
      <Private path={"/*"} />
      <Public path={"/*"} />
    </Router>
  );
};

Implmentation

I am new to this library (coming from react-router for an updated version of my techno) and the code doesn't seem very explicit to me, but as I saw the corresponding code is utils.pick but I don't see how to modify it correctly.

@SimonChaumet
Copy link
Author

I just saw it, but it could also be great to allow absolute paths in nested routes

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

No branches or pull requests

1 participant