Skip to content

Commit

Permalink
handle possibly undefined values on fileuploader stories
Browse files Browse the repository at this point in the history
  • Loading branch information
rssilva committed Nov 11, 2024
1 parent 236ee86 commit 1b146d2
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ export const WithUppy = (): React.ReactElement => {
};

uppy.on("file-added", (file) => {
setFileInformation({ fileName: file.name, fileSize: `${file.size} bytes` });
setFileInformation({
fileName: String(file.name),
fileSize: `${file.size} bytes`,
});
// Start single upload
});

Expand All @@ -186,12 +189,15 @@ export const WithUppy = (): React.ReactElement => {
});

uppy.on("complete", (result) => {
const file = result.successful[0];
setFileInformation({
fileName: file.name,
fileSize: `${file.size} bytes`,
fileUrl: file.uploadURL,
});
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (result.successful) {
const file = result.successful[0];
setFileInformation({
fileName: String(file.name),
fileSize: `${file.size} bytes`,
fileUrl: file.uploadURL,
});
}
});

return (
Expand Down

0 comments on commit 1b146d2

Please sign in to comment.