I need to add a parameter in each route of my application, this parameter should stay in the route when I use the redirect, how do I do this?
The way that works is add manually the param in every path, something like this:
const useCustomParams = (): { customParam: string }=> {
const { search } = useLocation()
const urlParams = useMemo(() => new URLSearchParams(search), [search])
const customParam = `?org=${urlParams.get('org') ?? ''}`
return { customParam }
}
...
const { customParam } = useCustomParams()
...
<Route
path="*"
element={<Navigate to={`/group/${id}/users${customParam}`} replace />}
/>
... or
navigate({`/group/${id}/users${customParam}`})