aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/layout/comment.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-30 11:18:11 +0100
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:15:27 +0100
commit84a679b0e48ed76eee2fa44d3caac83591aa3c8c (patch)
tree1d418a6c514ff8a04b84ba35c98736e8450f968c /src/components/organisms/layout/comment.tsx
parent60c49f18389ff625177a57277ef8f292a31097bf (diff)
feat(hooks): add useBoolean and useToggle hooks
Diffstat (limited to 'src/components/organisms/layout/comment.tsx')
-rw-r--r--src/components/organisms/layout/comment.tsx13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/components/organisms/layout/comment.tsx b/src/components/organisms/layout/comment.tsx
index db7cb3a..adbb2cc 100644
--- a/src/components/organisms/layout/comment.tsx
+++ b/src/components/organisms/layout/comment.tsx
@@ -1,11 +1,11 @@
/* eslint-disable max-statements */
import NextImage from 'next/image';
import Script from 'next/script';
-import { type FC, useCallback, useState } from 'react';
+import type { FC } from 'react';
import { useIntl } from 'react-intl';
import type { Comment as CommentSchema, WithContext } from 'schema-dts';
import type { SingleComment } from '../../../types';
-import { useSettings } from '../../../utils/hooks';
+import { useSettings, useToggle } from '../../../utils/hooks';
import { Button, Link, Time } from '../../atoms';
import {
Card,
@@ -49,12 +49,7 @@ export const UserComment: FC<UserCommentProps> = ({
}) => {
const intl = useIntl();
const { website } = useSettings();
- const [isReplying, setIsReplying] = useState<boolean>(false);
-
- const handleReply = useCallback(
- () => setIsReplying((prevState) => !prevState),
- []
- );
+ const [isReplying, toggleIsReplying] = useToggle(false);
if (!approved) {
return (
@@ -170,7 +165,7 @@ export const UserComment: FC<UserCommentProps> = ({
{canReply ? (
<CardFooter>
<CardActions>
- <Button kind="tertiary" onClick={handleReply}>
+ <Button kind="tertiary" onClick={toggleIsReplying}>
{buttonLabel}
</Button>
</CardActions>