Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: prevent crash when accessing route params in notes/notebook screens

kashaf-ansari-devedc95631946e
diff --git a/apps/mobile/app/screens/notebook/index.tsx b/apps/mobile/app/screens/notebook/index.tsx
index 08e30c9a4..263d05d4a 100644
--- a/apps/mobile/app/screens/notebook/index.tsx
+++ b/apps/mobile/app/screens/notebook/index.tsx
@@ -45,7 +45,9 @@ import { getGroupOptions } from "../../hooks/use-group-options";
const NotebookScreen = ({ route, navigation }: NavigationProps<"Notebook">) => {
const [notes, setNotes] = useState<VirtualizedGrouping<Note>>();
- const params = useRef<NotebookScreenParams>(route?.params);
+ const params = useRef<NotebookScreenParams>(
+ route?.params || ({} as NotebookScreenParams)
+ );
const isAppLoading = useSettingStore((state) => state.isAppLoading);
const [notebook, setNotebook] = useState<Notebook | undefined>(
params.current.item
diff --git a/apps/mobile/app/screens/notes/index.tsx b/apps/mobile/app/screens/notes/index.tsx
index 423daa669..f93a82726 100644
--- a/apps/mobile/app/screens/notes/index.tsx
+++ b/apps/mobile/app/screens/notes/index.tsx
@@ -71,7 +71,9 @@ const NotesPage = ({
focusControl = true,
rightButtons
}: RouteProps<"NotesPage" | "TaggedNotes" | "Monographs" | "ColoredNotes">) => {
- const params = useRef<NotesScreenParams>(route?.params);
+ const params = useRef<NotesScreenParams>(
+ route?.params || ({} as NotesScreenParams)
+ );
const [notes, setNotes] = useState<VirtualizedGrouping<Note>>();
const [loadingNotes, setLoadingNotes] = useState(true);
const isMonograph = route.name === "Monographs";