<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gustavribeirod on Medium]]></title>
        <description><![CDATA[Stories by Gustavribeirod on Medium]]></description>
        <link>https://medium.com/@gustavribeirod?source=rss-3140a9afa106------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AN0mAiQGtVBPq-NMWZIhvQ.png</url>
            <title>Stories by Gustavribeirod on Medium</title>
            <link>https://medium.com/@gustavribeirod?source=rss-3140a9afa106------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 10:16:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gustavribeirod/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[React Native: Instagram “double tap” like animation with reanimated.]]></title>
            <link>https://medium.com/@gustavribeirod/react-native-instagram-double-tap-like-effect-with-reanimated-330797726bc5?source=rss-3140a9afa106------2</link>
            <guid isPermaLink="false">https://medium.com/p/330797726bc5</guid>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[double-tap]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react-native-reanimated]]></category>
            <dc:creator><![CDATA[Gustavribeirod]]></dc:creator>
            <pubDate>Fri, 25 Nov 2022 14:59:27 GMT</pubDate>
            <atom:updated>2023-08-21T17:03:27.720Z</atom:updated>
            <content:encoded><![CDATA[<p>How to create the Instagram <strong>double tap </strong>like effect with <strong>react-native-reanimated</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/0*gi0c2PrX4aK375s8" /></figure><h3>Getting started with our example</h3><p>create project example:</p><pre>expo init instagram-like-effect</pre><p>I will be using <a href="https://docs.expo.dev/">expo</a> with <a href="https://docs.expo.dev/introduction/managed-vs-bare/#bare-workflow">bare workflow</a> and <a href="https://www.typescriptlang.org/">typescript</a> for this example, but you can fell free to use any workflow you prefer.</p><p>Once the app has been created, let’s add typescript to the Bare Workflow.</p><p>You can follow the <a href="https://docs.expo.dev/guides/typescript/"><strong>Using TypeScript</strong></a><strong> </strong>expo guide.</p><h3>Next, install the following packages:</h3><pre>yarn add styled-components</pre><pre>yarn add @types/styled-components-react-native -D</pre><pre>yarn add react-native-reanimated</pre><blockquote><em>for </em><strong><em>react-native-reanimated, </em></strong><em>add Reanimated’s Babel plugin to your </em><em>babel.config.js :</em></blockquote><pre>module.exports = {<br>    presets: [<br>      ...<br>    ],<br>    plugins: [<br>      ...<br>      &#39;react-native-reanimated/plugin&#39;,<br>    ],<br>  };</pre><pre>expo install @expo/vector-icons</pre><pre>expo install react-native-gesture-handler</pre><h3>Then set up our app structure</h3><pre>mkdir src<br>mkdir src/images<br>mkdir src/Post/ &amp;&amp; touch src/Post/index.tsx &amp;&amp; src/Post/styles.ts</pre><p>download these <a href="https://github.com/Guribeiro/react-native-instagram-like-effect/tree/instagram-like-style/src/assets/heart">heart icons</a> and put them in the src/images directory.</p><h3>Next, paste the following in src/Post/styles.ts</h3><pre>import { View, Image } from &#39;react-native&#39;;<br>import styled, { css } from &#39;styled-components/native&#39;;<br>import { Feather } from &#39;@expo/vector-icons&#39;<br><br>interface IconProps {<br>  isLiked?: boolean;<br>}<br><br>export const Container = styled(View)`<br>flex: 1;<br>justify-content: center;<br>align-items: center;<br>padding: 20px;<br><br>background: #151417;<br>`;<br><br>export const PostImageContainer = styled(View)`<br>width: 100%;<br>height: 300px;<br>`;<br><br>export const PostImage = styled(Image)`<br>width: 100%;<br>height: 100%;<br>`;<br><br>export const HeartLikeImage = styled(Image)`<br>width: 96px;<br>height: 96px;<br>`;<br><br>export const Icon = styled(Feather) &lt;IconProps&gt;`<br>color: #FFFFFF;<br>font-size: 24px;<br><br>${({ isLiked }) =&gt; isLiked &amp;&amp; css`<br>  color: #e74c3c;<br>`}<br>`;<br><br>export const InteractionContainer = styled(View)`<br>width: 100%;<br>margin-top: 16px;<br>flex-direction: row;<br>align-items: center;<br>`;</pre><h3>Next, paste the following in src/Post/index.tsx</h3><pre>import React, { useState } from &#39;react&#39;;<br>import { TouchableOpacity } from &#39;react-native&#39;;<br>import { TapGestureHandler } from &#39;react-native-gesture-handler&#39;;<br>import Animated, {<br>  useSharedValue,<br>  useAnimatedStyle,<br>  withTiming,<br>  Easing,<br>  runOnJS<br>} from &#39;react-native-reanimated&#39;;<br>import heartImage from &#39;../assets/heart/heart-like.png&#39;;<br><br>import {<br>  Container,<br>  PostImageContainer,<br>  PostImage,<br>  HeartLikeImage,<br>  InteractionContainer,<br>  Icon<br>} from &#39;./styles&#39;;<br><br>export default function Post() {<br><br>  const [isLiked, setIsLiked] = useState(false);<br><br>  const likeImageOpacity = useSharedValue(0);<br>  const likeImageScale = useSharedValue(1);<br><br>  const iconLikeStyle = useAnimatedStyle(() =&gt; {<br>    return {<br>      opacity: likeImageOpacity.value,<br>      transform: [{ scale: likeImageScale.value }],<br>      width: &#39;100%&#39;,<br>      height: &#39;100%&#39;,<br>      justifyContent: &#39;center&#39;,<br>      alignItems: &#39;center&#39;,<br>      display: &#39;flex&#39;,<br>      position: &#39;absolute&#39;,<br>    }<br>  });<br><br>  const likePost = () =&gt; {<br>    setIsLiked(prev =&gt; !prev);<br>  }<br><br>  const handleLikePostIndicator = () =&gt; {<br>    likeImageOpacity.value = withTiming(<br>      1,<br>      {<br>        duration: 200,<br>        easing: Easing.ease<br>      }, () =&gt; {<br>        &#39;worklet&#39;<br>        runOnJS(likePost)();<br>        likeImageScale.value = withTiming(<br>          1.25,<br>          {<br>            duration: 200,<br>            easing: Easing.ease<br>          }, () =&gt; {<br>            likeImageScale.value = withTiming(<br>              1,<br>              {<br>                duration: 200,<br>                easing: Easing.ease<br>              },<br>              () =&gt; {<br>                likeImageOpacity.value = withTiming(<br>                  0,<br>                  {<br>                    duration: 300,<br>                    easing: Easing.ease<br>                  }<br>                )<br>              }<br>            )<br>          }<br>        )<br>      }<br>    )<br>  };<br><br>  return (<br>    &lt;Container&gt;<br>      &lt;TapGestureHandler numberOfTaps={2} onActivated={handleLikePostIndicator}&gt;<br>        &lt;PostImageContainer&gt;<br>          &lt;PostImage source={{ uri: &#39;https://images.pexels.com/photos/8388229/pexels-photo-8388229.jpeg?auto=compress&amp;cs=tinysrgb&amp;w=1260&amp;h=750&amp;dpr=1&#39; }} /&gt;<br>          &lt;Animated.View style={iconLikeStyle}&gt;<br>            &lt;HeartLikeImage source={heartImage} /&gt;<br>          &lt;/Animated.View&gt;<br>        &lt;/PostImageContainer&gt;<br>      &lt;/TapGestureHandler&gt;<br><br>      &lt;InteractionContainer&gt;<br>        &lt;TouchableOpacity onPress={handleLikePostIndicator}&gt;<br>          &lt;Icon isLiked={isLiked} name=&#39;heart&#39; /&gt;<br>        &lt;/TouchableOpacity&gt;<br>      &lt;/InteractionContainer&gt;<br>    &lt;/Container&gt;<br>  );<br>}<br><br></pre><h3>Next, paste the following in App.tsx</h3><pre>import Post from &quot;./src/Post&quot;<br><br>const App = ():JSX.Element =&gt; {<br>  return &lt;Post /&gt;<br>}<br><br>export default App</pre><p>We can start our project now, you can choose between:</p><pre>yarn run ios</pre><pre>yarn run android</pre><pre>expo start</pre><p>You can like the post by pressing the heart icon right below the post image or just double tapping the post image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*7G4PWdOYd0s9BchyH35B6A.gif" /></figure><h3>Yeaaahhh!!! We did it!!!! 🎉🎉🎉</h3><p>That’s our double tap instagram like effect.</p><p>You can find the source code in this <a href="https://github.com/Guribeiro/react-native-instagram-like-effect">repository</a></p><p>There are two branches, you’ll find the blank app, which is the <a href="https://github.com/Guribeiro/react-native-instagram-like-effect/tree/main"><strong>main </strong></a>branch and the <a href="https://github.com/Guribeiro/react-native-instagram-like-effect/tree/instagram-like-style"><strong>instagram-like-style</strong></a><strong> </strong>branch which contains the full source code.</p><h3>⭐️ Credits</h3><p><a href="https://oieduardorabelo.medium.com/react-native-efeito-double-tap-estilo-instagram-5b858acb6e2b"><strong>React Native: Efeito “double tap” estilo Instagram</strong></a>, by <a href="https://medium.com/u/feb605976cbf">Eduardo Rabelo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=330797726bc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>