From 179baa3777c21710a2032c63add5b0c19f08efe9 Mon Sep 17 00:00:00 2001 From: srgooglo Date: Fri, 4 Jul 2025 14:11:49 +0200 Subject: [PATCH] Refactor LikeButton to use named function component --- .../components/actions/likeButton/index.jsx | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/packages/app/src/components/PostCard/components/actions/likeButton/index.jsx b/packages/app/src/components/PostCard/components/actions/likeButton/index.jsx index cb7cc217..f6aa55a2 100755 --- a/packages/app/src/components/PostCard/components/actions/likeButton/index.jsx +++ b/packages/app/src/components/PostCard/components/actions/likeButton/index.jsx @@ -4,56 +4,56 @@ import CountUp from "react-countup" import "./index.less" -export default (props) => { - const [liked, setLiked] = React.useState(props.defaultLiked ?? false) - const [clicked, setCliked] = React.useState(false) +const LikeButtonAction = (props) => { + const [liked, setLiked] = React.useState(props.defaultLiked ?? false) + const [clicked, setCliked] = React.useState(false) - const handleClick = async () => { - let to = !liked + const handleClick = async () => { + let to = !liked - setCliked(to) + setCliked(to) - if (typeof props.onClick === "function") { - const result = await props.onClick(to) - if (typeof result === "boolean") { - to = result - } - } + if (typeof props.onClick === "function") { + const result = await props.onClick(to) - setLiked(to) - } + if (typeof result === "boolean") { + to = result + } + } - return
- - -
-} \ No newline at end of file + setLiked(to) + } + + return ( +
+ + +
+ ) +} + +export default LikeButtonAction