<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: hirensavalias</title>
    <description>The latest articles on DEV Community by hirensavalias (@hirensavalias).</description>
    <link>https://dev.to/hirensavalias</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F320743%2Fa804dcdb-84fe-47af-becd-f3b1da0cf453.png</url>
      <title>DEV Community: hirensavalias</title>
      <link>https://dev.to/hirensavalias</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hirensavalias"/>
    <language>en</language>
    <item>
      <title>Create Instagram "Like" button in React Native with animated  API</title>
      <dc:creator>hirensavalias</dc:creator>
      <pubDate>Wed, 24 Mar 2021 17:37:42 +0000</pubDate>
      <link>https://dev.to/hirensavalias/create-instagram-like-button-in-react-native-p5f</link>
      <guid>https://dev.to/hirensavalias/create-instagram-like-button-in-react-native-p5f</guid>
      <description>&lt;p&gt;the simplest(maybe not the best) way to create a like button that bounces on press.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, {  useState, useRef } from "react";
import { FontAwesome } from "@expo/vector-icons";
import { Animated, View } from "react-native";

const AnimatedIcon = Animated.createAnimatedComponent(FontAwesome);

export const Like = ({ item, style }) =&amp;gt; {
  const scale = useRef(new Animated.Value(1)).current;
  const opacity = useRef(new Animated.Value(1)).current;
  const reverseOpacity = useRef(new Animated.Value(0)).current;
  const [liked, setLiked] = useState(false);

  const like = (value) =&amp;gt; {
    Animated.sequence([
      Animated.timing(scale, {
        toValue: 0.9,
        duration: 50,
        useNativeDriver: true,
      }),
      Animated.timing(scale, {
        toValue: 1.2,
        duration: 150,
        useNativeDriver: true,
      }),
      Animated.timing(scale, {
        toValue: 0.9,
        duration: 50,
        useNativeDriver: true,
      }),
      Animated.parallel([
        Animated.timing(scale, {
          toValue: 1,
          duration: 200,
          useNativeDriver: true,
        }),
        Animated.timing(value ? opacity : reverseOpacity, {
          toValue: 0,
          duration: 90,
          useNativeDriver: true,
        }),
        Animated.timing(value ? reverseOpacity : opacity, {
          toValue: 1,
          duration: 90,
          useNativeDriver: true,
        }),
      ]),
    ]).start();
    setLiked(value);
  };

  return (
    &amp;lt;View&amp;gt;
      &amp;lt;AnimatedIcon
        name={"heart"}
        size={30}
        style={{
          ...style,
          position: "absolute",
          opacity: reverseOpacity,
          transform: [{ scale }],
        }}
        color="#B00000"
        onPress={() =&amp;gt; like(!liked)}
      /&amp;gt;
      &amp;lt;AnimatedIcon
        name={"heart-o"}
        size={30}
        style={{
          ...style,
          opacity: opacity,
          transform: [{ scale }],
        }}
        color="black"
        onPress={() =&amp;gt; like(!liked)}
      /&amp;gt;
    &amp;lt;/View&amp;gt;
  );
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>reactnative</category>
      <category>instagram</category>
      <category>like</category>
      <category>animated</category>
    </item>
  </channel>
</rss>
