aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/LikeButton.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/common/LikeButton.tsx')
-rw-r--r--src/components/common/LikeButton.tsx12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/components/common/LikeButton.tsx b/src/components/common/LikeButton.tsx
index f817bd98..43b3ac37 100644
--- a/src/components/common/LikeButton.tsx
+++ b/src/components/common/LikeButton.tsx
@@ -4,23 +4,25 @@ import {normalize} from '../../utils';
interface LikeButtonProps {
onPress: () => void;
- filled: boolean;
style: ImageStyle;
+ initialLikeState: boolean;
}
const LikeButton: React.FC<LikeButtonProps> = ({
onPress,
- filled: initialFillState,
style,
+ initialLikeState,
}) => {
- const [filled, setFilled] = useState(initialFillState);
+ const [filled, setFilled] = useState(initialLikeState);
const uri = filled
? require('../../assets/images/heart-filled.png')
: require('../../assets/images/heart-outlined.png');
return (
<TouchableOpacity
onPress={() => {
- setFilled(!filled);
- onPress();
+ if (filled === initialLikeState) {
+ setFilled(!filled);
+ onPress();
+ }
}}>
<Image style={[styles.image, style]} source={uri} />
</TouchableOpacity>