From 5541106f8eef4b8d871ef6de213809216a9a44f8 Mon Sep 17 00:00:00 2001 From: robines Date: Fri, 22 Nov 2024 20:13:18 +0100 Subject: [PATCH] Remove enabled argument from UserFeedback (fixes top-level hooks error) It's also better to disable the component by just not rendering it, instead of dealing with enabled state. --- frontend/src/App.tsx | 2 +- .../Components/UserFeedback/UserFeedback.stories.tsx | 2 +- frontend/src/Components/UserFeedback/UserFeedback.tsx | 10 +--------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 05f886d01..e65530c9e 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -28,7 +28,7 @@ export function App() { return ( - + {goatCounterCode && ( {/* Helmet is linked to . Used to add scripts. */} diff --git a/frontend/src/Components/UserFeedback/UserFeedback.stories.tsx b/frontend/src/Components/UserFeedback/UserFeedback.stories.tsx index fc0feae02..03aae52a0 100644 --- a/frontend/src/Components/UserFeedback/UserFeedback.stories.tsx +++ b/frontend/src/Components/UserFeedback/UserFeedback.stories.tsx @@ -8,7 +8,7 @@ export default { } as ComponentMeta; const Template: ComponentStory = () => { - return ; + return ; }; export const Primary = Template.bind({}); diff --git a/frontend/src/Components/UserFeedback/UserFeedback.tsx b/frontend/src/Components/UserFeedback/UserFeedback.tsx index 711b3172d..d9b3a537a 100644 --- a/frontend/src/Components/UserFeedback/UserFeedback.tsx +++ b/frontend/src/Components/UserFeedback/UserFeedback.tsx @@ -10,23 +10,15 @@ import { useTextItem } from '~/hooks'; import { KEY } from '~/i18n/constants'; import styles from './UserFeedback.module.scss'; -type UserFeedbackProps = { - enabled: boolean; -}; - type FormProps = { text: string; contact_email?: string; }; -export function UserFeedback({ enabled }: UserFeedbackProps) { +export function UserFeedback() { const { t } = useTranslation(); const [isOpen, setIsOpen] = useState(false); - if (!enabled) { - return
; - } - const handleFormSubmit = (formData: FormProps) => { postFeedback({ ...formData,