Open hamsterhomka opened 1 year ago
Created two files
1) usePathname.ts
import { usePathname as useExpoPathname } from 'expo-router'
export const usePathname = () => {
return useExpoPathname()
}
2) usePathname.web.ts
import { usePathname as useNextPathname } from 'next/navigation'
export const usePathname = () => {
return useNextPathname()
}
And it worked perfectly!
Hm interesting. Well what you did is correct!
- usePathname.web.ts
import { usePathname as useNextPathname } from 'next/navigation' export const usePathname = () => { return useNextPathname() }
@hamsterhomka usePathname
from solito/navigation
works and does exactly that, so you could just do:
import { usePathname } from 'solito/navigation'
export { usePathname }
Trying to figure out a way to get the expected behaviour on native without the expo/router
dependency but no luck so far.
The comment can be edited though, it doesn't work with the expo router.
@nandorojo Is there a relevant way to add a warning about this unexpected behaviour ?
Yeah we probably need a config variable for expo router at the root
Is there an existing issue for this?
Do you want this issue prioritized?
Current Behavior
usePathname()
returnsundefined
in expo application with expo-router.Expected Behavior
Work the same as in next.js
Steps To Reproduce
No response
Versions
Screenshots
I think that
usePathname
from 'solito/navigation' should useusePathname
from 'expo-router' under the hood instead ofuseContext(NavigationRouteContext)
Reproduction
No response