Skip to content

Commit

Permalink
refactor: use switch statements instead of else-if
Browse files Browse the repository at this point in the history
  • Loading branch information
pnxl committed Aug 13, 2023
1 parent 62ddbc6 commit cd213ec
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utils/getFileIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ export const getFileIcon = (file: any) => {
const fileExtension = file.name.split(".").pop().toLowerCase();
const imageFileExtensions = ["png", "jpg", "jpeg", "gif", "webp"];

if (imageFileExtensions.indexOf(fileExtension) !== -1) {
return <IconFileImageOutline class="text-xl" />;
} else {
return <IconFileOutline class="text-xl" />;
switch (true) {
case imageFileExtensions.indexOf(fileExtension) !== -1:
return <IconFileImageOutline class="text-xl" />;
default:
return <IconFileOutline class="text-xl" />;
}
};

0 comments on commit cd213ec

Please sign in to comment.