Comments (9)
My question is—if I want the
LinkComponent
to always go to/sub/url
, even when used on line 17, what would you suggest?
Just use ~/sub/url
. The base path for default router is always /
from wouter.
Hi @jeerbl, could you share a piece of code? This is supposed to work.
from wouter.
Hi @molefrog, I made a CodeSandbox. I've actually seen something strange, looking deeper into the problem.
What I'm trying to do is to have the same component in two different contexts, go to the same URL, and Wouter actually does, but the href
set on the <a>
element is for some reason wrong and different than the path Wouter actually navigates to.
In that example, if you access /sub/url
, you'll see the link prefixed with ~
go to the actually root URL /url
. When you're in /url
, the <Link>
still goes to /url
(which is what I want), but the URL displayed in href
attribute of the <a>
element is actually /sub/url
.
First thing is, what should happen here in my opinion is to have the <a>
href
element to be the same as where Wouter navigates to.
Second thing is, should Wouter actually ignore the hrefs
when navigating? Is this what's expected? It benefits my case but I'm not sure if that's what's expected here.
from wouter.
but the URL displayed in
href
attribute of the<a>
element is actually/sub/url
.
That's because you have a custom hrefs formatter, if you remove it you the href will be /url
isn't that something you want?
from wouter.
The hrefs
only affects the href
attribute rendered and it is mostly needed for server-side rendering (e.g. when you use hash-based routing, the html rendered must be <a href="#/" />
and not <a href="/" />
). It does not affect the actual client-side navigation.
from wouter.
I see, thank you. So just formatting and nothing else.
Closing this.
from wouter.
Actually reopening this for advice. I updated the CodeSandbox.
Here, in this new piece of code, the component LinkComponent
is going to /url
so, in the <Router base="/sub">
this link will be /sub/url
and in the first <Router>
line 17, it will go to /url
.
My question is—if I want the LinkComponent
to always go to /sub/url
, even when used on line 17, what would you suggest?
I would want all links under the <Router>
line 14 to always add /sub
to the route.
from wouter.
Hi @jeerbl is this issue still relevant?
from wouter.
Hi @molefrog, actually it isn't! Closing this issue :)
from wouter.
Related Issues (20)
- Typescript problem with Route and react-error-boundary
- Avoiding race conditions when updating search HOT 6
- build bug HOT 2
- Incorrect matching in paths with wildcards HOT 1
- Uncaught TypeError: Cannot read properties of undefined (reading 'context') HOT 1
- Content of pages inside nesting routes HOT 3
- [Feature Request] Support for the View Transition API HOT 1
- Using `useSearch` with SSR throws a hydration warning
- Memory location does not include a search hook HOT 3
- Add support for Hono Client Components HOT 9
- Allow using `RegExp` for paths alongside strings HOT 1
- Meta: Add `.gitattributes` file HOT 2
- Prevent "back button" navigation HOT 4
- Transpile the build for older browsers. HOT 2
- Consider exposing `matchRoute` helper function HOT 3
- break out of nest and keep base HOT 2
- Route nesting is not working as per docs HOT 1
- Path component with prefixes is not supported in v3 HOT 1
- wouter Switch matches less-specific Route for 1 render when using browser 'back' button
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wouter.