Replies: 1 comment 1 reply
-
Ah figure it out. instead of: const search = useSearch({from: '/ }) I had to do this instead: import { indexRoute } from "../router";
/**
* export const indexRoute = new Route({
* getParentRoute: () => rootRoute,
* path: "/",
* component: Map,
* validateSearch: (search) => indexSearchSchema.parse(search),
});
**/
const search = useSearch({ from: indexRoute.id }); and i could also refactor to this with TS moaning: const {lat, lng} = useSearch({ from: indexRoute.id }); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently tinkering with a very simple mapping application and would like to sync the coordinates of the map with search params. Something slightly annoying which I'm not sure how handle is that the
useSearch
hook returns a union of an empty object and my expected type. e.g:Here is how I have configured my route:
perhaps my mental model is incorrect. But I assumed that because I've validated the params in
validateSearch
we should be able assume we definitely have those search params available to use. I dont like the ergonomics of having to check the object is not empty every time. Hope this all makes and someone can advise 🙏Beta Was this translation helpful? Give feedback.
All reactions