Commit 5000c046 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Treat route query params as optional

parent 89c6d398
......@@ -22,7 +22,7 @@ function AnnotationView({
onLogin,
}: AnnotationViewProps) {
const store = useSidebarStore();
const annotationId = store.routeParams().id;
const annotationId = store.routeParams().id ?? '';
const rootThread = useRootThread();
const userid = store.profile().userid;
......
......@@ -14,7 +14,7 @@ export type StreamSearchInputProps = {
*/
function StreamSearchInput({ router }: StreamSearchInputProps) {
const store = useSidebarStore();
const query = store.routeParams().q;
const { q } = store.routeParams();
const setQuery = (query: string) => {
// Re-route the user to `/stream` if they are on `/a/:id` and then set
// the search query.
......@@ -22,7 +22,7 @@ function StreamSearchInput({ router }: StreamSearchInputProps) {
};
return (
<SearchInput query={query} onSearch={setQuery} alwaysExpanded={true} />
<SearchInput query={q ?? ''} onSearch={setQuery} alwaysExpanded={true} />
);
}
......
......@@ -19,7 +19,7 @@ const initialState = {
* - The "stream" route has a "q" (query) parameter.
* - The "sidebar" route has no parameters.
*
* @type {Record<string, string>}
* @type {Record<string, string | undefined>}
*/
params: {},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment