From 02189a67bda972840b03cd1fa5f5035a684059de Mon Sep 17 00:00:00 2001 From: Ludy Date: Mon, 29 Sep 2025 14:01:09 +0200 Subject: [PATCH] refactor(frontend): remove unused React default imports (#4529) ## Description of Changes - Removed unused `React` default imports across multiple frontend components. - Updated imports to only include required React hooks and types (e.g., `useState`, `useEffect`, `Suspense`, `createContext`). - Ensured consistency with React 17+ JSX transform, where default `React` import is no longer required. - This cleanup reduces bundle size slightly and aligns code with modern React best practices. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com> --- frontend/src/App.tsx | 2 +- .../src/components/shared/FilePickerModal.tsx | 2 +- .../components/shared/FileUploadButton.tsx | 2 +- frontend/src/components/shared/Footer.tsx | 1 - .../components/shared/MultiSelectControls.tsx | 11 +++--- .../shared/NavigationWarningModal.tsx | 1 - .../shared/RainbowThemeProvider.tsx | 2 +- .../src/components/toast/ToastRenderer.tsx | 11 +++--- .../src/components/tools/ToolRenderer.tsx | 4 +-- .../AddWatermarkSingleStepSettings.tsx | 5 ++- .../addWatermark/WatermarkFormatting.tsx | 3 +- .../tools/addWatermark/WatermarkImageFile.tsx | 1 - .../addWatermark/WatermarkStyleSettings.tsx | 3 +- .../tools/addWatermark/WatermarkTextStyle.tsx | 3 +- .../tools/automate/AutomationSelection.tsx | 9 +++-- .../BookletImpositionSettings.tsx | 4 +-- .../tools/compress/CompressSettings.tsx | 2 +- .../convert/ConvertFromEmailSettings.tsx | 1 - .../convert/ConvertFromImageSettings.tsx | 1 - .../tools/convert/ConvertFromWebSettings.tsx | 1 - .../tools/convert/ConvertSettings.tsx | 2 +- .../tools/convert/ConvertToImageSettings.tsx | 1 - .../tools/convert/ConvertToPdfaSettings.tsx | 1 - .../tools/convert/GroupedFormatDropdown.tsx | 36 +++++++++---------- .../tools/pageLayout/PageLayoutSettings.tsx | 1 - .../ReorganizePagesSettings.tsx | 3 +- .../replaceColor/ReplaceColorSettings.tsx | 3 +- .../components/tools/shared/FileMetadata.tsx | 3 +- .../tools/shared/NavigationControls.tsx | 1 - .../tools/shared/NumberInputWithUnit.tsx | 20 +++++------ .../tools/shared/OperationButton.tsx | 1 - .../tools/shared/ResultsPreview.tsx | 2 +- .../components/tools/sign/SignSettings.tsx | 4 +-- .../tools/toolPicker/ToolSearch.tsx | 2 +- .../components/viewer/CustomSearchLayer.tsx | 20 +++++------ .../viewer/LocalEmbedPDFWithAnnotations.tsx | 4 +-- .../components/viewer/PdfViewerToolbar.tsx | 12 +++---- .../components/viewer/ThumbnailSidebar.tsx | 2 +- frontend/src/components/viewer/Viewer.tsx | 3 +- frontend/src/contexts/FileContext.tsx | 2 +- frontend/src/contexts/SidebarContext.tsx | 6 ++-- frontend/src/tools/OCR.tsx | 2 +- frontend/src/tools/RemovePages.tsx | 1 - frontend/src/tools/ReorganizePages.tsx | 2 +- 44 files changed, 90 insertions(+), 113 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index da9a14eb5..529da2643 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import React, { Suspense } from "react"; +import { Suspense } from "react"; import { RainbowThemeProvider } from "./components/shared/RainbowThemeProvider"; import { FileContextProvider } from "./contexts/FileContext"; import { NavigationProvider } from "./contexts/NavigationContext"; diff --git a/frontend/src/components/shared/FilePickerModal.tsx b/frontend/src/components/shared/FilePickerModal.tsx index fde20f014..9bb2694a1 100644 --- a/frontend/src/components/shared/FilePickerModal.tsx +++ b/frontend/src/components/shared/FilePickerModal.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import { useState, useEffect } from 'react'; import { Modal, Text, diff --git a/frontend/src/components/shared/FileUploadButton.tsx b/frontend/src/components/shared/FileUploadButton.tsx index 434aad1b4..f09cc19d0 100644 --- a/frontend/src/components/shared/FileUploadButton.tsx +++ b/frontend/src/components/shared/FileUploadButton.tsx @@ -1,4 +1,4 @@ -import React, { useRef } from "react"; +import { useRef } from "react"; import { FileButton, Button } from "@mantine/core"; import { useTranslation } from "react-i18next"; diff --git a/frontend/src/components/shared/Footer.tsx b/frontend/src/components/shared/Footer.tsx index 137914617..0c94efa0e 100644 --- a/frontend/src/components/shared/Footer.tsx +++ b/frontend/src/components/shared/Footer.tsx @@ -1,5 +1,4 @@ import { Flex } from '@mantine/core'; -import React from 'react'; import { useTranslation } from 'react-i18next'; import { useCookieConsent } from '../../hooks/useCookieConsent'; diff --git a/frontend/src/components/shared/MultiSelectControls.tsx b/frontend/src/components/shared/MultiSelectControls.tsx index 11790abf8..b6e0b24b9 100644 --- a/frontend/src/components/shared/MultiSelectControls.tsx +++ b/frontend/src/components/shared/MultiSelectControls.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { Box, Group, Text, Button } from "@mantine/core"; import { useTranslation } from "react-i18next"; @@ -37,7 +36,7 @@ const MultiSelectControls = ({ > {t("fileManager.clearSelection", "Clear Selection")} - + {onAddToUpload && (