aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/LikeButton.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-05-11 17:55:43 -0400
committerIvan Chen <ivan@tagg.id>2021-05-11 17:55:43 -0400
commit58ab56d0b03491dd062d09e2ee96fe8f88e74bc9 (patch)
tree38f836031c042e254d412b60ba7436431379bbeb /src/components/common/LikeButton.tsx
parent69c07634befdad4be416df843ecb803e760c5883 (diff)
fixed issue, basic functionality working
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>