From 8fac4c0708802b1e44a716fbc876a462cae224b7 Mon Sep 17 00:00:00 2001 From: Huu Le <20178761+huult@users.noreply.github.com> Date: Sun, 3 Nov 2024 22:00:20 +0700 Subject: [PATCH] handle undefined fileName parameter in route params --- .../HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx | 2 +- src/pages/home/report/ReportAttachments.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx index 06512f04bb95..43177be408ff 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx @@ -73,7 +73,7 @@ function ImageRenderer({tnode}: ImageRendererProps) { let fileName = htmlAttribs[CONST.ATTACHMENT_ORIGINAL_FILENAME_ATTRIBUTE] || FileUtils.getFileName(`${isAttachmentOrReceipt ? attachmentSourceAttribute : htmlAttribs.src}`); const fileInfo = FileUtils.splitExtensionFromFileName(fileName); if (!fileInfo.fileExtension) { - fileName = `${fileInfo.fileName || CONST.DEFAULT_IMAGE_FILE_NAME}.jpg`; + fileName = `${fileInfo?.fileName || CONST.DEFAULT_IMAGE_FILE_NAME}.jpg`; } const thumbnailImageComponent = ( diff --git a/src/pages/home/report/ReportAttachments.tsx b/src/pages/home/report/ReportAttachments.tsx index c4895de3fea5..871d692b59a3 100644 --- a/src/pages/home/report/ReportAttachments.tsx +++ b/src/pages/home/report/ReportAttachments.tsx @@ -20,7 +20,7 @@ function ReportAttachments({route}: ReportAttachmentsProps) { const isAuthTokenRequired = route.params.isAuthTokenRequired; const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`); const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); - const fileName = route.params.fileName; + const fileName = route.params?.fileName; // In native the imported images sources are of type number. Ref: https://reactnative.dev/docs/image#imagesource const source = Number(route.params.source) || route.params.source;