diff --git a/reader/src/ViewPage.jsx b/reader/src/ViewPage.jsx index b085251..61b9880 100644 --- a/reader/src/ViewPage.jsx +++ b/reader/src/ViewPage.jsx @@ -17,7 +17,10 @@ export function ViewPage() { const [selectedIdx, setSelectedIdx] = useState(0); const options = useMemo(() => { - return data?.options.map((option) => { + if (!data || data.options.length === 0) { + return []; + } + return data.options.map((option) => { let fileContent = option.text || "**No Data!**"; fileContent = marked.parse(fileContent); @@ -45,7 +48,7 @@ export function ViewPage() { `; return { ...option, text: fileContent }; }); - }, [data?.options]); + }, [data]); useEffect(() => { socket.on("connect", () => setIsConnected(true)); @@ -68,7 +71,7 @@ export function ViewPage() { } }, [config.contentZoomLevel]); - if (!data) { + if (!data || options.length === 0) { return (
@@ -152,7 +155,7 @@ export function ViewPage() {
-
+
{options.map((option, optionIdx) => (