<?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: Uwem</title>
    <description>The latest articles on DEV Community by Uwem (@uwemisrael).</description>
    <link>https://dev.to/uwemisrael</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%2F398975%2Fd9172a13-f999-478b-b623-d4bb0f39cf02.jpg</url>
      <title>DEV Community: Uwem</title>
      <link>https://dev.to/uwemisrael</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uwemisrael"/>
    <language>en</language>
    <item>
      <title>How to add image preloading animation to a react native component using reanimated2</title>
      <dc:creator>Uwem</dc:creator>
      <pubDate>Wed, 29 Dec 2021 09:18:19 +0000</pubDate>
      <link>https://dev.to/uwemisrael/how-to-add-image-preloading-animation-to-a-react-native-component-using-reanimated2-39ce</link>
      <guid>https://dev.to/uwemisrael/how-to-add-image-preloading-animation-to-a-react-native-component-using-reanimated2-39ce</guid>
      <description>&lt;p&gt;Hello, how about we make our react native app a little bit fancy by adding preloading animations to our image component using the awesome &lt;a href="https://docs.swmansion.com/react-native-reanimated/"&gt;reanimated2 library&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll wrap the the Image component in an animated view having the same dimension as the image and create a state to manage the image status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Animated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;interpolateColor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;useAnimatedStyle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;useSharedValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;withTiming&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-native-reanimated&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Props&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="cm"&gt;/**base64 string or url for the image */&lt;/span&gt;
  &lt;span class="nl"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AppImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;Props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isImageLoading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsImageLoading&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Animated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[{&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="p"&gt;}]}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Animated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Image&lt;/span&gt;
        &lt;span class="p"&gt;{...{&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;uri&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;
        &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[{&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="p"&gt;}]&lt;/span&gt;
        &lt;span class="nx"&gt;resizeMethod&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;auto&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;resizeMode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cover&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Animated.View&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;AppImage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The image opacity  will be set to 0 on mounting while we animated the background of the animated view with a loop animation&lt;br&gt;
When the image is loaded, we'll stop the loop animation and set the image opacity to 1&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Animated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;interpolateColor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;useAnimatedStyle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;useSharedValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;withTiming&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-native-reanimated&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Props&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="cm"&gt;/**base64 string or url for the image */&lt;/span&gt;
  &lt;span class="nl"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AppImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;Props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isImageLoading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsImageLoading&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;loop&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useSharedValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// this will be used to control the animation of the image container&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animatedContainerStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useAnimatedStyle&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;interpolateColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;black&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="c1"&gt;// animate the background color of the image container&lt;/span&gt;
  &lt;span class="p"&gt;}));&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animatedImageStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useAnimatedStyle&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;withTiming&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isImageLoading&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="c1"&gt;// fade in image when loaded&lt;/span&gt;
  &lt;span class="p"&gt;}));&lt;/span&gt;

  &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="na"&gt;animationInterval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NodeJS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Timeout&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;//start animation when the component mounts&lt;/span&gt;
    &lt;span class="nx"&gt;animationInterval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;withTiming&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;250&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;//stop animation when the image is loaded&lt;/span&gt;
    &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isImageLoading&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animationInterval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animationInterval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//cleanup&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isImageLoading&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Animated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[{&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;animatedContainerStyle&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Animated&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Image&lt;/span&gt;
        &lt;span class="p"&gt;{...{&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;uri&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;
        &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{[{&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;animatedImageStyle&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;
        &lt;span class="nx"&gt;onLoad&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;setIsImageLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}}&lt;/span&gt;
        &lt;span class="nx"&gt;resizeMethod&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;auto&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;resizeMode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cover&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Animated.View&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;AppImage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a preview&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CTHTK9WH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ba8szb1wttmlm01utri.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CTHTK9WH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ba8szb1wttmlm01utri.gif" alt="Preview" width="480" height="1072"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>reactnative</category>
      <category>react</category>
    </item>
    <item>
      <title>How to send custom emails from a spreadsheet using google apps script.</title>
      <dc:creator>Uwem</dc:creator>
      <pubDate>Sun, 25 Apr 2021 08:10:32 +0000</pubDate>
      <link>https://dev.to/uwemisrael/how-to-send-custom-emails-from-a-spreadsheet-using-google-apps-script-2n0n</link>
      <guid>https://dev.to/uwemisrael/how-to-send-custom-emails-from-a-spreadsheet-using-google-apps-script-2n0n</guid>
      <description>&lt;p&gt;We are in an age where most of us are constantly seeking an easier way to do things, especially in professional settings where there is a lot of repeated task.  If you're currently looking for an easier way to send emails directly from your spreadsheet, well, you're in luck because this blog post is for you.&lt;br&gt;
&lt;a href="https://i.giphy.com/media/MqxZxTlvcY5BS/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/MqxZxTlvcY5BS/giphy.gif" alt="Giffy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post will be focusing on Google sheets because it's one of the coolest spreadsheets ever, and together with the google apps script, it turns into the hulk on steroids. If this is your first time hearing about apps script, here's a summary of it.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/JJgmU_JUsug"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Now let us begin.&lt;/p&gt;

&lt;p&gt;Let us assume that the task of sending a series of acceptance /rejection emails to job applicants was assigned to us, and for each email, we are to include the job position of the candidate and the status of their application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step One:
&lt;/h2&gt;

&lt;p&gt;Create a template for the email we want to send in google docs.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E5DdTM3h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/DO82xCT.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E5DdTM3h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/DO82xCT.png" alt="Imgur"&gt;&lt;/a&gt;&lt;br&gt;
You'll notice that in the email template above, we have place-holders for the applicant's name, position applied for, and status(i.e, accepted and rejected)&lt;/p&gt;
&lt;h2&gt;
  
  
  Step two:
&lt;/h2&gt;

&lt;p&gt;We'll create a spreadsheet with values that we want to replace our placeholders with (Name, Position, and status) and add a send email button at the button of the sheet.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ec1Ffqju--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/bOEUCpe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ec1Ffqju--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/bOEUCpe.png" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step Three:
&lt;/h2&gt;

&lt;p&gt;It's time for the fun part. Open the script editor by clicking on 'tools' located in the ribbon section and select script editor. The script editor will be opened in a new tab.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AyKSYRtd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/4O3eoTj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AyKSYRtd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/4O3eoTj.png" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First&lt;/strong&gt;, we'll write a function that takes applicant details and creates a custom email from the template, then sends an email to the applicant&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function createDocument(name, email, position, status){
  //get the email template from google doc using the url of the file
  const templateUrl = 'https://docs.google.com/document/d/1sRHXLlb3nsaiGVodhPNdt0SeYE1Gy-UnB4HQ1r2Wn-8/edit'

  //Get that template
  const template = DocumentApp.openByUrl(templateUrl)

  // Extract the text in the body of the documemt
  const text = template.getBody().getText()

  //Replace all placeholders
  const emailBody = text.replace('#Name', name)
              .replace('#position', position)
              .replace('#status', status)


  MailApp.sendEmail(
    email,
    'Response to Job Application',
    emailBody
  )
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Next&lt;/strong&gt;, we'll create a second function that takes rows of data from the spreadsheet and calls the &lt;code&gt;createDocument&lt;/code&gt; function on each row. The last action by this function will be to alert us that all emails have been sent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sendEmails() {
  //get the spreadsheet with the emails
  const emialSpreadsheet =  SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()

  //get all data inside the spreadsheet
  const data = emialSpreadsheet.getDataRange().getValues()

  //Iteriate through the data
  data.forEach((applicant, index) =&amp;gt; {
    if (index &amp;gt; 0) //Skips the first array which is the header
    {
      createDocument(...applicant)
    }
  })

  SpreadsheetApp.getUi().alert('ALL Emails have been sent') //Show an alert on google sheet that the mails have been sent.
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally we are going to assign the function above to the 'send email' button on the spreadsheet.&lt;br&gt;
*Right click on the button&lt;br&gt;
*Click on the three vertical dots to the left and select "Assign Script&lt;br&gt;
*Type in "sendEmails" (this is the name of the function that we wish to assign to the button)&lt;/p&gt;

&lt;p&gt;And that's it. Now with the click of a button, you can send as many customized emails as you want. Oh! wait!!, I forgot to mention that Google has a limit on the number of emails you can send using Apps script, which is 100/day for basic google accounts(e.g., gmail.com) and 1500/day for workspace accounts.&lt;/p&gt;

&lt;p&gt;Enjoy your new superpower.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>googlecloud</category>
    </item>
    <item>
      <title>MY JOURNEY SO FAR AS AN ASPIRING WEB DEVELOPER</title>
      <dc:creator>Uwem</dc:creator>
      <pubDate>Tue, 07 Jul 2020 12:41:10 +0000</pubDate>
      <link>https://dev.to/uwemisrael/my-journey-so-far-as-an-aspiring-web-developer-3m48</link>
      <guid>https://dev.to/uwemisrael/my-journey-so-far-as-an-aspiring-web-developer-3m48</guid>
      <description>&lt;p&gt;&lt;strong&gt;Two&lt;/strong&gt; months ago, I started the #100DaysOFCode challenge with Java in mind, I learnt the basics along with some advanced concepts of java but got bored quick because I wasn’t excited with the things I created, everything was stuck in the console, 😢 there was no UI and my laptop specs couldn’t afford android studio. I told a friend and he advised that I switch to web development, introduced me to FreeCodeCamp and encouraged me to give it a try.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A&lt;/strong&gt; new week started, and I put aside my java notes and created a new one for web development, logged on to FreeCodeCamp with an open mind not knowing what to expect and started the responsive web design course and boy!! was I glad I listened to my friend advice. Before the end of that that day I knew how to create headers, footers, ordered lists and so much more and guess what? It was all &lt;code&gt;console&lt;/code&gt; free. Over the next few weeks that followed, I was able to create basic side projects, I had just learnt how to add images to a web page and I wasn’t going to let that knowledge go to waste.😎&lt;/p&gt;

&lt;p&gt;The Html5 section of FreeCodeCamp was a no brainer, finished it and moved on to the CSS section. Here, I had to pause and take things slow to fully understand things. I was learning how to breathe life into web pages using CSS and it was just A-M-A-Z-I-N-G😆. Things got a little bit technical with CSS FlexBox and GRID systems, but I was able to grasp Flexbox and skipped GRID  because I just couldn't wrap my head around it😕.&lt;/p&gt;

&lt;p&gt;I finally finished the course and was overjoyed because now, it was time to use my new ability to build mind blowing web pages😁. How naive I was 😅. &lt;/p&gt;

&lt;p&gt;Scanned through the Web design projects and thought, oh! this is easy, and you know what, I’m going to make my own unique😇, for the tribute page I thought of doing a slideshow with a timeline, for the survey project I thought of doing some cool animations with the forms and I was all hyped up💪. Pumped myself up with lots of tutorial videos, created a workspace in VScode and I was ready to unleash the &lt;strong&gt;&lt;em&gt;genius&lt;/em&gt;&lt;/strong&gt; in me, but there was just one problem, my div element refused to stay in the center of the screen😭, &lt;strong&gt;I flexed it, justified it, aligned it&lt;/strong&gt; and nope!!, it just wont stay put, there was short moments of victory where it would center and the moment  I added another element everything would go haywire and the div elements would start flying here and there like they were in a dance competition. To add insult on injury my images were putting up some magic performance of their own. I went to bed frustrated that night thinking, maybe web Design isn’t for me, maybe I should have stayed in the peaceful world of &lt;code&gt;System.out.println()&lt;/code&gt;😪.&lt;/p&gt;

&lt;p&gt;The next day I opened twitter to see if I could get motivated from the &lt;code&gt;#100DAYSOFCODE&lt;/code&gt; community which is a great community by the way, lots of awesome stuff on that trend. &lt;strong&gt;&lt;em&gt;I saw a tweet that stressed the importance of baby steps, taking things slow and breaking down problems into bits&lt;/em&gt;&lt;/strong&gt;, another tweet said &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tutorials doesn’t make you a better developer, practice does&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These tweets really helped reshaped my unrealistic expectations and made me understand that in other to get better i needed to practice more, humble myself and learn from my mistakes.&lt;/p&gt;

&lt;p&gt;I decided to follow FreeCodeCamp models for the projects, opened up chrome devTools and inspected how they their set up was, Calmly, I observed how they positioned each element, the amount of padding and margins on some tags, what type of display some elements on the page had and when I didn’t understand the need for a particular style, I would change it and observe how if affected the layout of the page.&lt;/p&gt;

&lt;p&gt;Little by little my project began to make sense. FreeCodeCamp’s forum was of great value also. If only you could have seen the big smile on my face when I passed the tribute page test, even if it was similar to that of FreeCodeCamp, I made it, and it wasn’t just a copy and paste project, I knew and understood how everything worked.&lt;/p&gt;

&lt;p&gt;True there were times when I was temped to go overboard again but I kept things simple and just tried my best to pass the user stories, although I couldn’t resist the urge with my product landing page. 😂&lt;/p&gt;

&lt;p&gt;Now I’m in the amazing world of JavaScript and oh! Yeah, turns out you can’t run from the ‘console’,  😂. But I’ll choose&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;over&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;anytime, anyday. &lt;/p&gt;

&lt;p&gt;So far, I think i've made some improvements, for example I use to struggle with centering a div but now some of my major struggles are, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what on earth am I going to name this variable? &lt;/li&gt;
&lt;li&gt;What’s up with promises and how do I use them&lt;/li&gt;
&lt;li&gt;Oh, My God!! I haven’t learnt AJAX!!!&lt;/li&gt;
&lt;li&gt;What the difference between prototypes and classes?&lt;/li&gt;
&lt;li&gt;What wrong with the &lt;code&gt;This&lt;/code&gt; keyword? Why does it keep changing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Occasionally, I still struggle with centering a div, but what the heck!! I’m making progress and building little cool projects. &lt;/p&gt;

&lt;p&gt;Maybe one day I’ll write about how a bug in one of my recent project almost made me cry myself to sleep but till then, keep coding, keep learning, drink lots of water and stay close to things that makes you happy. BYE 😆.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>100daysofcode</category>
    </item>
  </channel>
</rss>
