Skip to content

Commit

Permalink
Remove enabled argument from UserFeedback (fixes top-level hooks error)
Browse files Browse the repository at this point in the history
It's also better to disable the component by just not rendering it,
instead of dealing with enabled state.
  • Loading branch information
robines committed Nov 22, 2024
1 parent cb9d4d5 commit 5541106
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function App() {

return (
<HelmetProvider>
<UserFeedback enabled={true} />
<UserFeedback />
{goatCounterCode && (
<Helmet>
{/* Helmet is linked to <head>. Used to add scripts. */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
} as ComponentMeta<typeof UserFeedback>;

const Template: ComponentStory<typeof UserFeedback> = () => {
return <UserFeedback enabled={true} />;
return <UserFeedback />;
};

export const Primary = Template.bind({});
10 changes: 1 addition & 9 deletions frontend/src/Components/UserFeedback/UserFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div />;
}

const handleFormSubmit = (formData: FormProps) => {
postFeedback({
...formData,
Expand Down

0 comments on commit 5541106

Please sign in to comment.