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

V3: Route nesting specs #343

Merged
merged 6 commits into from Sep 27, 2023
Merged

V3: Route nesting specs #343

merged 6 commits into from Sep 27, 2023

Conversation

molefrog
Copy link
Owner

/** Route nesting proposal **/

// 1. Routes always match the full path, unless it is used as parent route
// 2. When nested route is defined, current location becomes scoped 

<Router base="/app">
  <Route path="/users/:id" nest> // base="/app"           location="/users/1"
    <Route path="/bio" />        // base="/app/users/1"   location="/bio"
    <Route path="/logs" />       // base="/app/users/1"   location="/logs"
   
    <Route hook={customHook} />  // base="/"
    <Route base="/new" />        // base="/app/users/new" (Router)
  </Route>

  <Switch>
    <Route path="/settings" />
    <Route path="/account" nest> // needs to match loose
      <Route path="/2fa" />
    </Route>
  </Switch>
</Router>

Breaking changes:

  • Router no longer accepts parent prop
  • Base is inherited from the parent router by default

@github-actions
Copy link

github-actions bot commented Sep 21, 2023

size-limit report 📦

Path Size
packages/wouter/esm/index.js 1.39 KB (0%)
packages/wouter/esm/use-location.js 664 B (0%)
packages/wouter-preact/esm/index.js 912 B (0%)
packages/wouter-preact/esm/use-location.js 200 B (0%)

@molefrog molefrog merged commit abaf9d2 into v3 Sep 27, 2023
2 checks passed
@molefrog molefrog deleted the feat/nesting-specs branch September 27, 2023 11:02
@molefrog molefrog mentioned this pull request Oct 9, 2023
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

Successfully merging this pull request may close these issues.

None yet

1 participant