`as` path doesn't work properly (or does it?)
nandorojo opened this issue · comments
It seems that router.on('routeChangeComplete', path => ...)
returns the asPath
for the path
argument. I need to clarify this still. But I'm trying to do something like this: router.push('/dashboard/my-artists/djkhaled', '/@djkhaled')
where the URL should show the asPath
/@djhkhaled
.
However, it seems that the LinkTo
component is trying to navigate to /@djkhaled
instead of the href
. This is breaking for me on Web, since my React Navigation linking config expects the more normal URL. So I'm going to look more into this.
It's possible we read from the Router
directly inside of the routeChangeComplete
event, since I would assume that that's all it's passing down to us anyway.
However, what is the desired behavior? Do we want React Navigation reading the as
path, or the href
? I think it should be the href
, since that lets us use the correct URLs for navigating within a specific tab, etc.
Discussion
This isn't a bug, but rather a discussion over desired behavior. I think React Navigation should deal with the normal paths, rather than asPath
s.
However, this wouldn't work for native deep linking.
In my case, I have a rewrite in Next.js. Any URL to /@:slug
→ /artists/[slug]
.
However, for deep linking into an app, if I send you beatgig.com/@djkhaled
on like iMessage, and you open it from your phone, the native app will handle that as /@djkhaled
, so we'd have to rewrite this here as well, presumably inside of getPathFromState
. 🥲
Ignore this, but more discussion at #17