Replies: 4 comments 5 replies
-
|
Context
Why Fix (minimum viable) Option A — use
|
Beta Was this translation helpful? Give feedback.
-
|
As you saw |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
el hash no esta disponible en request.url porque el navegador nunca lo manda al servidor, es solo del lado del cliente. por eso window.location.hash es la unica forma real de pillarlo si lo necesitas en el clientLoader puedes hacer algo asi: export async function clientLoader({ request }: Route.ClientLoaderArgs) {
const url = new URL(request.url)
const hash = typeof window !== "undefined" ? window.location.hash : ""
// ya tienes el hash
}aunque si lo que quieres es reaccionar a cambios de hash te conviene mas usar un useEffect con un listener en el componente directamente, el clientLoader no se re-ejecuta cuando cambia el hash |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I need to read url parts (pathname, search etc) from clientLoader I do:
but request.url doesn't have a hash so my
location.hashwill not be set. How do I work around that?I can get the hash by using
window.location.hashbut that works only for initial load because on subsequent navigations window.location still shows old/current location when clientLoader runsBeta Was this translation helpful? Give feedback.
All reactions