<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ gif - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ gif - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 26 May 2026 16:23:52 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/gif/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Convert Video Files to a Gif in Python ]]>
                </title>
                <description>
                    <![CDATA[ Recently, I was able to convert some video files to a gif as I needed them in gif format for some of my articles. I decided to show you how I did it in 3 lines of code, so you can save yourself the extra effort of looking up a ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-convert-video-files-to-gif-in-python/</link>
                <guid isPermaLink="false">66adf10b2d0eb5bfdd6b0c24</guid>
                
                    <category>
                        <![CDATA[ gif ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ video ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kolade Chris ]]>
                </dc:creator>
                <pubDate>Thu, 31 Mar 2022 16:06:08 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/03/convert.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Recently, I was able to convert some video files to a gif as I needed them in gif format for some of my articles.</p>
<p>I decided to show you how I did it in 3 lines of code, so you can save yourself the extra effort of looking up a Saas to do it for you.</p>
<h2 id="heading-how-to-convert-video-to-a-gif-in-python">How to Convert Video to a Gif in Python</h2>
<p>To convert video to gif in Python, you need to install a package called <code>moviepy</code> with pip by opening your terminal and running <code>pip install moviepy</code>.</p>
<p>This module has several methods with which you can edit and enhance videos.
<img src="https://www.freecodecamp.org/news/content/images/2022/03/ss1-3.png" alt="ss1-3" width="600" height="400" loading="lazy"></p>
<p>After successfully installing <code>moviepy</code>, you need to import a method called <code>VideoFileClip</code> from it. This is the method with which you will be able to specify the name of the video file and its relative path.</p>
<pre><code class="lang-py"><span class="hljs-keyword">from</span> moviepy.editor <span class="hljs-keyword">import</span> VideoFileClip
</code></pre>
<p>The next thing you need to do is to specify the relative path of the video you want to convert to a gif inside the VideoFileClip method. Then you need to assign it to a variable. </p>
<p>In the code snippet below, I call that variable <code>videoClip</code>:</p>
<pre><code class="lang-py">videoClip = VideoFileClip(<span class="hljs-string">"my-life.mp4"</span>)
</code></pre>
<p>To finally convert the video to gif, you need to bring in the <code>videoClip</code> variable and use the <code>write_gif()</code> method on it, then specify the name you want to give to the gif inside it.</p>
<pre><code class="lang-py">videoClip.write_gif(<span class="hljs-string">"my-life.gif"</span>)
</code></pre>
<p>Open the terminal and run the file:
<img src="https://www.freecodecamp.org/news/content/images/2022/03/ss2-1.png" alt="ss2-1" width="600" height="400" loading="lazy"></p>
<p>Check the folder inside which the video file is located and you should see the gif file. If you’re using VS Code, open the sidebar by pressing <code>CTRL + B</code> and you should see the gif file.
<img src="https://www.freecodecamp.org/news/content/images/2022/03/ss3-1.png" alt="ss3-1" width="600" height="400" loading="lazy"></p>
<p>You can open the gif with VS Code too.</p>
<p>The whole code that did the conversion looks like this:</p>
<pre><code class="lang-py"><span class="hljs-keyword">from</span> moviepy.editor <span class="hljs-keyword">import</span> VideoFileClip

videoClip = VideoFileClip(<span class="hljs-string">"my-life.mp4"</span>)

videoClip.write_gif(<span class="hljs-string">"my-life.gif"</span>)
</code></pre>
<p>You can learn more about the <code>moviepy</code> module on <a target="_blank" href="https://zulko.github.io/moviepy/">their official website</a>.</p>
<p>If you have any questions, feel free to contact me on <a target="_blank" href="https://twitter.com/Ksound22">Twitter</a>.</p>
<p>Thank you for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Make a gif – Create Animated gifs Without Downloading Software ]]>
                </title>
                <description>
                    <![CDATA[ A GIF (Graphics Interchange Format) is a small animated image that you can share with your friends and family. And there are many ways to create them without downloading any software. In this article, I will show you how to use the Make a Gif  site, ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-make-a-gif-create-animated-gifs-without-downloading-software/</link>
                <guid isPermaLink="false">66b8d9912755c964523f0562</guid>
                
                    <category>
                        <![CDATA[ gif ]]>
                    </category>
                
                    <category>
                        <![CDATA[ how-to ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jessica Wilkins ]]>
                </dc:creator>
                <pubDate>Mon, 01 Nov 2021 21:31:16 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/11/carol-magalhaes-dSsXm15D9hg-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>A GIF (Graphics Interchange Format) is a small animated image that you can share with your friends and family. And there are many ways to create them without downloading any software.</p>
<p>In this article, I will show you how to use the <a target="_blank" href="https://makeagif.com/">Make a Gif</a>  site, where you can create GIFs with just a few short steps.</p>
<h2 id="heading-how-to-use-make-a-gif">How to Use "Make a GIF"</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-12.55.19-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><a target="_blank" href="https://makeagif.com/">Make a Gif</a> is a site where you can use your own images and videos to make your own GIFs. You can create an account with an email and password or your Facebook and Twitter account.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-12.58.40-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Once you have signed up, you can get started by uploading personal images, personal videos, Facebook urls, or YouTube urls.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.08.52-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>I am going to choose the first option which is to create a GIF from personal images.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.11.11-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You will then be taken to an editor.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.15.09-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Click on the Upload Images button or Drag and Drop images to Upload from your computer. You need to have at least two images to create a GIF. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.20.45-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>When you are finished adding all of the images, then click on the Continue to Editing button on the bottom right hand side. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.21.23-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In the editor, you can choose to resize your image, add captions, stickers and control the speed of the animation.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.25.59-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>When you are finished editing, click on the publishing button located on the bottom right hand corner. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.26.45-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>From there, you can give your GIF a title, category and tag names.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.29.29-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>When you are ready to publish your GIF, click on Create Your GIF located on the bottom right hand corner. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.28.49-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.29.52-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Once it is finished processing, you can see your new GIF in action.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.48.23-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can share your GIF with popular social media sites including Facebook, Twitter, and Reddit. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.34.16-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can also get the direct link to the GIF by clicking on the link icon.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.48.46-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.49.28-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you are interested in more features, including personalized watermarks, High Definition GIFs and no advertisements, then you can sign up for the <a target="_blank" href="https://makeagif.com/premium/trial?ref=4Yielk">Premium membership.</a></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/11/Screen-Shot-2021-11-01-at-1.53.52-AM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>And that's it! Have fun making your own GIFs.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Giphy API Tutorial – How to Generate Animated Text GIFs with ReactJS ]]>
                </title>
                <description>
                    <![CDATA[ By Charles M. In this tutorial you will create an app that generates dynamic animated text using Giphy's API with ReactJS. After that I'll go over some of the other API features Giphy provides that you can use to make other interesting projects. You ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/giphy-api-tutorial/</link>
                <guid isPermaLink="false">66d45dd73dce891ac3a967bc</guid>
                
                    <category>
                        <![CDATA[ api ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ frontend ]]>
                    </category>
                
                    <category>
                        <![CDATA[ gif ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 26 May 2021 21:44:01 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/05/giphy-API-tutorial.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Charles M.</p>
<p>In this tutorial you will create an app that generates dynamic animated text using Giphy's API with ReactJS.</p>
<p>After that I'll go over some of the other API features Giphy provides that you can use to make other interesting projects.</p>
<p>You can find the <a target="_blank" href="https://github.com/renaissanceengineer/reactjs-giphy-api-tutorial">code for the tutorial here</a>.</p>
<h2 id="heading-video-tutorial">Video Tutorial</h2>
<p>To see a preview of the finished product in action, you can watch the start of this video. If you prefer to follow a video tutorial instead of reading (or in addition to reading), you can also follow along for the rest of the video. </p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/H8JpzxRoS18" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-getting-started">Getting Started</h2>
<p>To get started you'll need a basic development environment for ReactJS. I'll be using create-react-app as the starting project template. </p>
<p>Next you'll need to visit <a target="_blank" href="https://developers.giphy.com">Giphy's developers page</a> and create an account so you can get your API key. Once you've created your account you'll see a dashboard like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/giphy-dashboard.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You need to click "create an App" and choose the SDK option for your app. Your dashboard will then present you with an API key you will use to make calls to the Giphy API. </p>
<h3 id="heading-how-to-setup-the-app-file-and-folder">How to Setup the App File and Folder</h3>
<p>The structure for this tutorial will be standard for ReactJS projects. Inside the <code>src</code> directory, create a <code>components</code> directory and create two files, <code>Error.js</code> and <code>TextList.js</code> </p>
<p>You also need to create a <code>.env</code> file in the root of the project that you'll use to store your API key. Whatever you name your variable, you need to append REACT_APP in front of it, like this:</p>
<p><code>REACT_APP_GIPHY_KEY=apikeyhere</code></p>
<h3 id="heading-install-giphy-js-fetch">Install Giphy JS-fetch</h3>
<p>The final thing you need to do is install Giphy's API helper library which you can do using the following command:</p>
<p><code>npm install @giphy/js-fetch-api</code></p>
<h2 id="heading-giphy-api-call">Giphy API Call</h2>
<p>The first task in making this app is creating an input form to accept the text you want to generate from the Giphy API. You will then use that text input and send it as an API request. </p>
<p>Before displaying this response data, let's test it out by simply making the API request and then logging the response. Write the following code in your <code>App.js</code> file:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { GiphyFetch } <span class="hljs-keyword">from</span> <span class="hljs-string">'@giphy/js-fetch-api'</span>
<span class="hljs-keyword">import</span> {useState} <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>
<span class="hljs-keyword">import</span> TextList <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/TextList'</span>
<span class="hljs-keyword">import</span> <span class="hljs-built_in">Error</span> <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/Error'</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">'./App.css'</span>;

<span class="hljs-keyword">const</span> giphy = <span class="hljs-keyword">new</span> GiphyFetch(process.env.REACT_APP_GIPHY_KEY)

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> [text, setText] = useState(<span class="hljs-string">''</span>)
  <span class="hljs-keyword">const</span> [results, setResults] = useState([])
  <span class="hljs-keyword">const</span> [err, setErr] = useState(<span class="hljs-literal">false</span>)

  <span class="hljs-keyword">const</span> handleInput = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    setText(e.target.value)
  }

  <span class="hljs-keyword">const</span> handleSubmit = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span>(text.length === <span class="hljs-number">0</span>) {

      <span class="hljs-comment">//set error state to true</span>
      setErr(<span class="hljs-literal">true</span>)
      <span class="hljs-keyword">return</span>
    }

    <span class="hljs-built_in">console</span>.log(text)

    <span class="hljs-keyword">const</span> apiCall = <span class="hljs-keyword">async</span> () =&gt; {
      <span class="hljs-keyword">const</span> res = <span class="hljs-keyword">await</span> giphy.animate(text, {<span class="hljs-attr">limit</span>: <span class="hljs-number">20</span>})
      <span class="hljs-built_in">console</span>.log(res.data)
      setResults(res.data)
    }

    apiCall()
    setText(<span class="hljs-string">''</span>)
    setErr(<span class="hljs-literal">false</span>)

  }

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"App"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Animated Text Generator<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Type text into the form and hit submit<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'input-field'</span> <span class="hljs-attr">value</span>=<span class="hljs-string">{text}</span> <span class="hljs-attr">onChange</span>=<span class="hljs-string">{handleInput}</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'submit-btn'</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleSubmit}</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<p>Let's take a look at what's happening in this code:</p>
<p><code>const giphy = new GiphyFetch(process.env.REACT_APP_GIPHY_KEY)</code> is where you use the Giphy helper library to create the object you'll use for interacting with the Giphy API. </p>
<p><code>process.env.REACT_APP_GIPHY_KEY</code> is how your API key is passed as an argument from the <code>.env</code> file. You can also pass your API key as a string, but you won't want to do this in production because somebody could steal and use your key.</p>
<p>Inside the main App component, you create three pieces of state using hooks. The 1st is <code>text</code> which will be what stores the user input. This is what will be passed to the API as an argument to generate text. </p>
<p><code>err</code> will be used to conditionally render an error later if the user attempts to submit an empty string. </p>
<p>And <code>results</code> is an empty array that will be used to store the results from the API response. </p>
<p>If you run the code and check your developer console, you should see that the Giphy API returned an array with 20 objects.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/console-results.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-display-the-data-with-react">How to Display the Data with React</h2>
<p>Now that the data is being properly stored in state, all you need to do is display that data with JSX.  To handle that, we'll finish those two components we created earlier. </p>
<p>First we'll make a simple error component that can display a custom message. Place the following code into <code>Error.js</code> inside your components folder:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> <span class="hljs-built_in">Error</span> = <span class="hljs-function">(<span class="hljs-params">props</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span>(!props.isError) {
        <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span>
    }

    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'error'</span>&gt;</span>{props.text}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>
    )
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-built_in">Error</span>
</code></pre>
<p>The <code>Error</code> component is very simple. It takes the <code>err</code> state and a text string as props, and if the value is true it will render the text. If <code>err</code> is false, it returns null.</p>
<p>Next is the TextList component which will take the <code>results</code> state as props and then display the data in your app:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> TextList = <span class="hljs-function">(<span class="hljs-params">props</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> items = props.gifs.map(<span class="hljs-function">(<span class="hljs-params">itemData</span>) =&gt;</span> {
    <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Item</span> <span class="hljs-attr">url</span>=<span class="hljs-string">{itemData.url}</span> /&gt;</span></span>;
  });
  <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"text-container"</span>&gt;</span>{items}<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>;
};
<span class="hljs-keyword">const</span> Item = <span class="hljs-function">(<span class="hljs-params">props</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"gif-item"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">{props.url}</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> TextList;
</code></pre>
<p>This component is a little more complicated, so here's what is happening:</p>
<p>The <code>Item</code> component accepts the URL value which is inside each value returned from the API. It uses this URL as the source for the image element.</p>
<p>The <code>results</code> state array from the App component is passed to the TextList component as <code>gifs</code>. The array is mapped over to generate all the <code>Item</code> components for all the results and assigned to the <code>items</code> variable and then returned inside a container div. We'll style this container later to create a grid layout.</p>
<h3 id="heading-how-to-import-the-components-into-the-main-app">How to Import the Components into the Main App</h3>
<p>Now you just need to use those finished components in your JSX. The final code of your <code>App.js</code> file should look like this:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> TextList <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/TextList'</span>
<span class="hljs-keyword">import</span> <span class="hljs-built_in">Error</span> <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/Error'</span>
<span class="hljs-keyword">import</span> { GiphyFetch } <span class="hljs-keyword">from</span> <span class="hljs-string">'@giphy/js-fetch-api'</span>
<span class="hljs-keyword">import</span> {useState} <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">'./App.css'</span>;

<span class="hljs-keyword">const</span> giphy = <span class="hljs-keyword">new</span> GiphyFetch(process.env.REACT_APP_GIPHY_KEY)

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> [text, setText] = useState(<span class="hljs-string">''</span>)
  <span class="hljs-keyword">const</span> [results, setResults] = useState([])
  <span class="hljs-keyword">const</span> [err, setErr] = useState(<span class="hljs-literal">false</span>)

  <span class="hljs-keyword">const</span> handleInput = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    setText(e.target.value)
  }

  <span class="hljs-keyword">const</span> handleSubmit = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span>(text.length === <span class="hljs-number">0</span>) {

      <span class="hljs-comment">//set error state to true</span>
      setErr(<span class="hljs-literal">true</span>)
      <span class="hljs-keyword">return</span>
    }

    <span class="hljs-built_in">console</span>.log(text)

    <span class="hljs-keyword">const</span> apiCall = <span class="hljs-keyword">async</span> () =&gt; {
      <span class="hljs-keyword">const</span> res = <span class="hljs-keyword">await</span> giphy.animate(text, {<span class="hljs-attr">limit</span>: <span class="hljs-number">20</span>})

      setResults(res.data)
    }

    apiCall()
    <span class="hljs-comment">//change error state back to false</span>
    setText(<span class="hljs-string">''</span>)
    setErr(<span class="hljs-literal">false</span>)

  }

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"App"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Animated Text Generator<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Type text into the form and hit submit<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'input-field'</span> <span class="hljs-attr">value</span>=<span class="hljs-string">{text}</span> <span class="hljs-attr">onChange</span>=<span class="hljs-string">{handleInput}</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'submit-btn'</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleSubmit}</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Error</span> <span class="hljs-attr">isError</span>=<span class="hljs-string">{err}</span> <span class="hljs-attr">text</span>=<span class="hljs-string">'need length longer than 0 for input'</span>/&gt;</span>
      {results &amp;&amp; <span class="hljs-tag">&lt;<span class="hljs-name">TextList</span> <span class="hljs-attr">gifs</span>=<span class="hljs-string">{results}</span>  /&gt;</span>}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<p>The only changes here are the bottom two lines added in the return statement:</p>
<p>The <code>Error</code> component is passed the <code>err</code> state and a <code>text</code> prop which will only be rendered if an error occurs. </p>
<p>In this app there is only one error condition in case the input is empty, but you could add additional checks with custom error messages as well.</p>
<p>Then we use conditional rendering with the <code>&amp;&amp;</code> logical operator. This causes the <code>TextList</code> component to render only if the results array is not empty, which means the API response returned successfully with our gifs.</p>
<p>If you run your code at this point, you should see an ugly but functional app. If you use the input field and click the submit button, the gifs should be returned and displayed in your app.</p>
<h2 id="heading-how-to-add-styling-with-css">How to Add Styling with CSS</h2>
<p>The last thing to do is make the app look a little bit prettier. Feel free to customize any of these styles if you want to adjust how things look. Place this code into your <code>App.css</code> file:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.App</span> {
  <span class="hljs-attribute">text-align</span>: center;
}

<span class="hljs-selector-class">.error</span> {
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#b50000</span>;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">20px</span>;
  <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">500</span>;
}


<span class="hljs-selector-class">.input-field</span> {
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">20px</span>;
  <span class="hljs-attribute">vertical-align</span>: middle;
  <span class="hljs-attribute">transition</span>: .<span class="hljs-number">5s</span>;
  <span class="hljs-attribute">border-width</span>: <span class="hljs-number">2px</span>;
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">5px</span>;
}

<span class="hljs-selector-class">.input-field</span><span class="hljs-selector-pseudo">:focus</span> {
  <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">0</span> <span class="hljs-number">14px</span> <span class="hljs-number">28px</span> <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0.25</span>), <span class="hljs-number">0</span> <span class="hljs-number">10px</span> <span class="hljs-number">10px</span> <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0.22</span>);
  <span class="hljs-attribute">outline</span>: none;
}

<span class="hljs-selector-class">.input-field</span><span class="hljs-selector-pseudo">:hover</span> {
  <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">0</span> <span class="hljs-number">14px</span> <span class="hljs-number">28px</span> <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0.25</span>), <span class="hljs-number">0</span> <span class="hljs-number">10px</span> <span class="hljs-number">10px</span> <span class="hljs-built_in">rgba</span>(<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0</span>,<span class="hljs-number">0.22</span>);

}

<span class="hljs-selector-class">.submit-btn</span> {
  <span class="hljs-attribute">background-color</span>: <span class="hljs-built_in">rgb</span>(<span class="hljs-number">19</span>, <span class="hljs-number">209</span>, <span class="hljs-number">235</span>);
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#fff</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">6px</span> <span class="hljs-number">30px</span>;
  <span class="hljs-attribute">vertical-align</span>: middle;
  <span class="hljs-attribute">outline</span>: none;
  <span class="hljs-attribute">border</span>: none;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">16px</span>;
  <span class="hljs-attribute">transition</span>: .<span class="hljs-number">3s</span>;
  <span class="hljs-attribute">cursor</span>: pointer;
}

<span class="hljs-selector-class">.submit-btn</span><span class="hljs-selector-pseudo">:hover</span> {
  <span class="hljs-attribute">background-color</span>: <span class="hljs-built_in">rgb</span>(<span class="hljs-number">10</span>, <span class="hljs-number">130</span>, <span class="hljs-number">146</span>);
}

<span class="hljs-selector-class">.text-container</span> {
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">flex-wrap</span>: wrap;
  <span class="hljs-attribute">justify-content</span>: center;
}

<span class="hljs-selector-class">.gif-item</span> {
  <span class="hljs-attribute">flex-basis</span>: <span class="hljs-number">19%</span>;
}

<span class="hljs-selector-tag">img</span> {
  <span class="hljs-attribute">max-width</span>: <span class="hljs-number">100%</span>;
}

<span class="hljs-keyword">@media</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">992px</span>) {
  <span class="hljs-selector-class">.gif-item</span> {
    <span class="hljs-attribute">flex-basis</span>: <span class="hljs-number">31%</span>;
  }
}

<span class="hljs-keyword">@media</span> screen <span class="hljs-keyword">and</span> (<span class="hljs-attribute">max-width:</span> <span class="hljs-number">600px</span>) {
  <span class="hljs-selector-class">.gif-item</span> {
    <span class="hljs-attribute">flex-basis</span>: <span class="hljs-number">48%</span>;
  }
}
</code></pre>
<p>Nothing crazy going on here with the CSS. Just some styling for the submit button and some box shadow for the input field. </p>
<p>There are also a few media queries for some responsive design that changes the column count depending on the screen size.</p>
<h2 id="heading-other-giphy-api-features">Other Giphy API features</h2>
<p>The animated text API is just one feature available in the Giphy API. I'll go over a few other features that could be useful as part of a project or as a solo project.</p>
<h3 id="heading-animated-emoji">Animated Emoji</h3>
<p>The Emoji endpoint is very straightforward in terms of use. It returns a bunch of animated emoji just like the animated text API you used above, except you don't need to pass any arguments to it. An example API call:</p>
<p><code>const data = await gf.emoji()</code></p>
<p>This endpoint could be useful if you are building a chat application and want to make it easy for users to use Emoji in their messages.</p>
<h3 id="heading-pre-built-ui-components">Pre-Built UI components</h3>
<p>If you don't feel like messing around with a ton of custom code like we did in this tutorial, Giphy actually provides components for both ReactJS and regular JavaScript. </p>
<p>You can make a grid very similar to what we created in this tutorial with just a few lines of code:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> { Grid } <span class="hljs-keyword">from</span> <span class="hljs-string">'@giphy/react-components'</span>
<span class="hljs-keyword">import</span> { GiphyFetch } <span class="hljs-keyword">from</span> <span class="hljs-string">'@giphy/js-fetch-api'</span>

<span class="hljs-comment">// use @giphy/js-fetch-api to fetch gifs</span>
<span class="hljs-comment">// apply for a new Web SDK key. Use a separate key for every platform (Android, iOS, Web)</span>
<span class="hljs-keyword">const</span> gf = <span class="hljs-keyword">new</span> GiphyFetch(<span class="hljs-string">'your Web SDK key'</span>)

<span class="hljs-comment">// fetch 10 gifs at a time as the user scrolls (offset is handled by the grid)</span>
<span class="hljs-keyword">const</span> fetchGifs = <span class="hljs-function">(<span class="hljs-params">offset: number</span>) =&gt;</span> gf.trending({ offset, <span class="hljs-attr">limit</span>: <span class="hljs-number">10</span> })

<span class="hljs-comment">// React Component</span>
ReactDOM.render(<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Grid</span> <span class="hljs-attr">width</span>=<span class="hljs-string">{800}</span> <span class="hljs-attr">columns</span>=<span class="hljs-string">{3}</span> <span class="hljs-attr">gutter</span>=<span class="hljs-string">{6}</span> <span class="hljs-attr">fetchGifs</span>=<span class="hljs-string">{fetchGifs}</span> /&gt;</span></span>, target)
</code></pre>
<p>You get some additional bonus features like automatic dynamic updates to fetch more content when users scroll to the bottom of the Grid. </p>
<p>You can choose between templates which handle almost everything or just a Grid component which gives you a little more control.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/05/giphy-ui-kits.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Here's an <a target="_blank" href="https://codesandbox.io/s/giphyreact-components-hbmcf?from-embed">interactive demo</a> provided by Giphy. </p>
<h3 id="heading-trending-api">Trending API</h3>
<p>This endpoint returns a list of constantly updated content based on user engagement and what is currently popular on Giphy.</p>
<h3 id="heading-search-api">Search API</h3>
<p>This endpoint is similar to the animated text endpoint, you just need to pass a search query as a parameter and you'll get an array of gifs that match.</p>
<p>There are many more API endpoints available. You can see the rest in <a target="_blank" href="https://developers.giphy.com/docs/api/endpoint">Giphy's API documentation</a>.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>That's it for this tutorial! I hope you found it interesting and you make some cool projects using the Giphy API.</p>
<p>If you are interested in a bunch of other cool APIs that you can use for making portfolio projects, you can check out this video as well which goes over 8 more APIs that I think are really cool.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/3ZRBDIA8C6E" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Things People Learning to Code will Understand: Part 2 ]]>
                </title>
                <description>
                    <![CDATA[ By Briana Marie When you write code you can be proud of: When you run your code for the first time, and it works as expected: When someone mentions white board algorithms: When you see brilliantly written code: When you realize you pushed to prod... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/things-people-learning-to-code-will-understand-part-2-6685cbed8c6/</link>
                <guid isPermaLink="false">66c3630540438b5931fe0985</guid>
                
                    <category>
                        <![CDATA[ Design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ gif ]]>
                    </category>
                
                    <category>
                        <![CDATA[ humor ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ women in tech ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 07 Feb 2016 07:55:24 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*51sjsyXx5sdvpSY1xuZQnQ.gif" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Briana Marie</p>
<p>When you write code you can be proud of:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*51sjsyXx5sdvpSY1xuZQnQ.gif" alt="Image" width="400" height="225" loading="lazy"></p>
<p>When you run your code for the first time, and it works as expected:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*AdMNtj1pZ2aoSZFpNUCnug.gif" alt="Image" width="480" height="270" loading="lazy"></p>
<p>When someone mentions white board algorithms:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*j8_AmX6lbwHXQGnQgxgmkQ.gif" alt="Image" width="500" height="237" loading="lazy"></p>
<p>When you see brilliantly written code:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*YFMGslBNPjScoNIbVMY4FQ.gif" alt="Image" width="273" height="240" loading="lazy"></p>
<p>When you realize you pushed to production too soon, and it’s too late to fix:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*Xcal3Yt7gLgposwM31Xqlw.gif" alt="Image" width="320" height="320" loading="lazy"></p>
<p>When somebody actually spends their time trying to convince you that JavaScript isn’t worth learning:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*jfQ-Q5gShv429IQutvj7Xg.gif" alt="Image" width="216" height="175" loading="lazy"></p>
<p>When you get to sit down and code after busting through red tape of chores and other work:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*DEF7jJXaS1Gufp2VkgSTDQ.gif" alt="Image" width="320" height="181" loading="lazy"></p>
<p>When you get an error you’ve ever seen before:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*sWgdITAiofQMHm0M_oFjbQ.gif" alt="Image" width="320" height="240" loading="lazy"></p>
<p>When someone says “Oh, I can make websites too, I use (insert template building site here)”</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*0mV8pafFISGEzX89grkYsw.gif" alt="Image" width="361" height="281" loading="lazy"></p>
<p>When you FINALLY fix that bug:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*mAk6aEhO5tDXb05ZOL1P1g.gif" alt="Image" width="500" height="302" loading="lazy"></p>
<p>When you FINALLY fix that bug, and then somehow, you didn’t actually:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*Sd0aEHTyAXRcz53iH8PmAQ.gif" alt="Image" width="600" height="255" loading="lazy"></p>
<p>Everything you hear about work/life balance in tech:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*eCMd5KdvO-pMg8cMomuWjA.gif" alt="Image" width="353" height="200" loading="lazy"></p>
<p>When — after hours of troubleshooting — all you to do was update a CDN link:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*tgck1Ok2ADxkCCgA3wk4bw.gif" alt="Image" width="371" height="242" loading="lazy"></p>
<p>When everyone on your team disagrees about React vs Angular 2:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*nZ2Yc54SXxtjE4NxbUiz-w.gif" alt="Image" width="500" height="281" loading="lazy"></p>
<p>Why would you <em>not</em> use JSX?</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*0oD41e9rRNstxSCu4OsCwQ.gif" alt="Image" width="500" height="311" loading="lazy"></p>
<p>When you hear “Women just make better designers than developers”:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*CzXthrAp3R0ysS1nzn8P7w.gif" alt="Image" width="500" height="282" loading="lazy"></p>
<p>When you force yourself to read documentation with a tired brain:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*kIl0NZsTU6jq-eUBaXRbGA.gif" alt="Image" width="500" height="213" loading="lazy"></p>
<p>When you start talking about all the reasons you are learning to code:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*gSBk2D8D72sTfv1THIz-Qw.gif" alt="Image" width="245" height="184" loading="lazy"></p>
<p>When someone says, “Learning to code is easy!”:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*On_N7eQ16PmOq_Bg59u1lQ.gif" alt="Image" width="500" height="206" loading="lazy"></p>
<p>When someone says “learning to code is hard, but worth it”:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*UF4k6lygsp54aK3nrND-AQ.gif" alt="Image" width="310" height="183" loading="lazy"></p>
<p>Can’t get enough? <a target="_blank" href="https://medium.freecodecamp.com/things-everyone-who-s-learning-to-code-will-understand-d289658ad263">Read part 1.</a></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
