<?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[ Segun Ajibola - 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[ Segun Ajibola - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 05 May 2026 22:19:33 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/segunajibola/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Build a Pokemon App with GraphQL and Apollo ]]>
                </title>
                <description>
                    <![CDATA[ Pokemon is a Japanese media franchise consisting of video games, animated series and films, a trading card game, and other related media. In this blog, we will be building with a Pokemon GraphQL API that gives us data about different Pokemons. We wil... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/build-a-pokemon-app-with-graphql-and-apollo/</link>
                <guid isPermaLink="false">66c8c949e9e57963a5d82ad0</guid>
                
                    <category>
                        <![CDATA[ Apollo GraphQL ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GraphQL ]]>
                    </category>
                
                    <category>
                        <![CDATA[ projects ]]>
                    </category>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Segun Ajibola ]]>
                </dc:creator>
                <pubDate>Wed, 03 Apr 2024 12:28:07 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/04/Parameters-vs-Arguments--2-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Pokemon is a Japanese media franchise consisting of video games, animated series and films, a trading card game, and other related media.</p>
<p>In this blog, we will be building with a Pokemon GraphQL API that gives us data about different Pokemons.</p>
<p>We will be using Apollo and GraphQL to handle the data fetching, and React for building our front-end application.</p>
<p>No worries if you don't know these technologies, I will be walking you through the basics as you read on.</p>
<h3 id="heading-prerequisites">Prerequisites</h3>
<p>You should have these in your computer to follow along:</p>
<ul>
<li>Nodejs v18+</li>
<li>A code editor</li>
<li>A web browser</li>
</ul>
<p>Let's create our React app.</p>
<h3 id="heading-react-application-setup">React Application Setup</h3>
<p>To create your React app, navigate to your terminal, and use the Command Prompt. Open your Command Prompt and choose your preferred location for creating your React project. Let's go with Desktop.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> Desktop
</code></pre>
<p>The above command will navigate to your Desktop.</p>
<pre><code class="lang-bash">npm create vite@latest pokemon-app -- --template react
</code></pre>
<p><code>npm create vite@latest</code> will start to build a new project using Vite. But we attached the name of our project (<code>pokemon-app</code>) and the technology or framework our app will be using (<code>-- -- template react</code>). </p>
<p>You can set another template like <code>svelte</code>, <code>vanilla</code> or <code>vue</code> and the project will be created using that framework. Read more about Vite on <a target="_blank" href="https://vitejs.dev/guide/">its official website</a>.</p>
<p>After the Vite installation, run the following commands:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> pokemon-app
npm install
npm run dev
</code></pre>
<p>We'll use the commands above to finish the React setup.</p>
<p>Run the first command, <code>cd pokemon-app</code>, to navigate to the <strong>pokeman-app</strong> folder.</p>
<p>Run <code>code .</code> to open the folder in your code editor.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1711666709423/593e293d-af0b-4cbd-b4ac-83d0c8213446.png" alt="Image" width="600" height="400" loading="lazy">
<em>modal displaying over VSCode to accept that you trust the authors of the files opened in VSCode</em></p>
<p>Mark the trust the author checkbox if that pops up.</p>
<p>Open your code editor's terminal. If you are running VSCode on Windows, the shortcut is `Ctrl + `` .</p>
<p>Run the other 2 commands in the terminal one after the other.</p>
<pre><code class="lang-bash">npm install
</code></pre>
<pre><code class="lang-bash">npm run dev
</code></pre>
<p>Your project should be running in the browser now.</p>
<p>We will be managing our data fetching using GraphQL and Apollo.</p>
<h2 id="heading-how-to-use-graphql-and-apollo">How to Use GraphQL and Apollo</h2>
<p>GraphQL is a query language for APIs and a runtime for fulfilling queries with your existing data. It allows you to request only the data you need in your application and nothing more, making it very efficient and flexible.</p>
<p>Apollo is a state management library that allows you to manage local and remote data with GraphQL. It can be used to fetch, cache, and modify application data, all while automatically updating your UI.</p>
<p>Let's install the packages you need.</p>
<h3 id="heading-installing-packages">Installing Packages</h3>
<p>Run the command below in your terminal to install the Apollo client.</p>
<pre><code class="lang-bash">npm install @apollo/client
</code></pre>
<p>Navigate to your <strong>main.jsx</strong> file and import these:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> ReactDOM <span class="hljs-keyword">from</span> <span class="hljs-string">"react-dom/client"</span>;
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">"./App.jsx"</span>;
<span class="hljs-keyword">import</span> {
  ApolloProvider,
  ApolloClient,
  InMemoryCache,
} <span class="hljs-keyword">from</span> <span class="hljs-string">"@apollo/client"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"./index.css"</span>;
</code></pre>
<p>You have imported React and ReactDOM for DOM manipulation.</p>
<p><code>ApolloClient</code> is responsible for managing your application's data fetching and state management. It handles sending GraphQL queries and mutations to your GraphQL server and caching the results.</p>
<p><code>ApolloProvider</code> will be used to wrap your React application to provide the Apollo Client instance to all your components so that your application can access data fetched through Apollo Client.</p>
<p><code>InMemoryCache</code> is a cache implementation to store the results of GraphQL queries in memory for efficient access and retrieval.</p>
<p>You have also imported <strong>index.css</strong> to style your application.</p>
<h3 id="heading-how-to-create-an-apollo-client">How to Create an Apollo Client</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> ApolloClient({
  <span class="hljs-attr">uri</span>: <span class="hljs-string">"https://graphql-pokemon2.vercel.app/"</span>,
  <span class="hljs-attr">cache</span>: <span class="hljs-keyword">new</span> InMemoryCache(),
});
</code></pre>
<p>The code above creates a new instance of <code>ApolloClient</code> with the some configurations:</p>
<ol>
<li><code>uri</code>: This specifies the URL of your GraphQL API endpoint. This is the endpoint where your Apollo Client will send GraphQL queries and mutations.</li>
<li><code>cache</code>: This configures the cache implementation for Apollo Client to use an in-memory cache to access data and store the result of GraphQL queries, reducing the need to re-fetch data from the server.</li>
</ol>
<p>You can now wrap your <code>&lt;App /&gt;</code> component with <code>ApolloProvider</code>:</p>
<pre><code class="lang-javascript">ReactDOM.createRoot(<span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"root"</span>)).render(
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">React.StrictMode</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ApolloProvider</span> <span class="hljs-attr">client</span>=<span class="hljs-string">{client}</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ApolloProvider</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">React.StrictMode</span>&gt;</span></span>
);
</code></pre>
<p>Note that <code>client</code> props was also passed to provide your application with <code>ApolloClient</code> configuration.</p>
<p>Go to your <strong>App.jsx</strong> component and input this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { PokemonsContainer } <span class="hljs-keyword">from</span> <span class="hljs-string">"./components/PokemonsContainer"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <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">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">PokemonsContainer</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span></span>
  );
}
</code></pre>
<p>You imported React and <code>PokemonsContainer</code> will be created. The <code>PokemonsContainer</code> component was wrapped in main tag and will be rendered when the component is pasted in the DOM.</p>
<p>Let's create the <code>PokemonsContainer</code> component in a file located in <strong>components</strong> folder. That is:</p>
<p>📂 src/components/PokemonsContainer.jsx</p>
<h3 id="heading-pokemons-container-component">Pokemons Container Component</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> { useQuery } <span class="hljs-keyword">from</span> <span class="hljs-string">"@apollo/client"</span>;
<span class="hljs-keyword">import</span> { Pokemon } <span class="hljs-keyword">from</span> <span class="hljs-string">"../components/Pokemon"</span>;
<span class="hljs-keyword">import</span> { GET_POKEMONS } <span class="hljs-keyword">from</span> <span class="hljs-string">"../graphql/get-pokemons"</span>;
</code></pre>
<p>The <code>useQuery</code> from <code>@apollo/client</code> is used for executing queries in an Apollo application. To do that, <code>useQuery()</code> is called and a GraphQL query string is passed as a argument. When your component renders, <code>useQuery</code> returns an object from Apollo Client that contains <code>loading</code>, <code>error</code>, and <code>data</code> properties that you can use to render your UI.</p>
<p><code>Pokemon</code> component was imported to render a user interface for a Pokemon, this will be built shortly.</p>
<p><code>GET_POKEMONS</code> was also imported. This will contain a GraphQL query.</p>
<p>After importing the above functions, continue building your page.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">PokemonsContainer</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> { loading, error, data } = useQuery(GET_POKEMONS, {
    <span class="hljs-attr">variables</span>: { <span class="hljs-attr">first</span>: <span class="hljs-number">5</span> },
  });

  <span class="hljs-keyword">if</span> (loading) <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Loading...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>;
  <span class="hljs-keyword">if</span> (error) <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Error: {error.message}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>;

  <span class="hljs-keyword">const</span> pokemons = data?.pokemons || [];
  <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">"container"</span>&gt;</span>
      {pokemons &amp;&amp;
        pokemons.map((pokemon) =&gt; (
          <span class="hljs-tag">&lt;<span class="hljs-name">Pokemon</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{pokemon.id}</span> <span class="hljs-attr">pokemon</span>=<span class="hljs-string">{pokemon}</span> /&gt;</span>
        ))}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}
</code></pre>
<p>As mentioned earlier, <code>useQuery</code> returns an object from Apollo Client that contains <code>loading</code>, <code>error</code>, and <code>data</code> properties. They are destructured here so you can access them in the page.</p>
<p>Notice that we're providing a configuration option (<code>variables</code>) to the <code>useQuery</code> hook. <code>{ variables: { first: 5 } }</code> was also passed as the second argument. The <code>variables</code> option is an object that contains all of the variables we want to pass to our GraphQL query. In this case, we passed an object <code>{ first: 5 }</code> to specify that we want the first five Pokemons.</p>
<p>If the query is still loading, <code>&lt;p&gt;Loading...&lt;/p&gt;</code> is returned to signify the user while <code>&lt;p&gt;Error: {error.message}&lt;/p&gt;</code> will be returned if there is an error.</p>
<p>The <code>pokemons</code> constant was created to hold the value of the Pokemons property of the data object. If <code>data.pokemons</code> is not available, the <code>pokemons</code> constant will be an empty array.</p>
<p>A div is returned with a <code>classname</code> of <code>container</code> which checks if <code>pokemons</code> is available and maps the array over the <code>Pokemon</code> component.</p>
<p>Let's create the <code>Pokemon</code> component:</p>
<p>📂src/components/Pokemon.jsx</p>
<h2 id="heading-pokemon-component">Pokemon Component</h2>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Pokemon</span>(<span class="hljs-params">{ pokemon }</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">"pokemon"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"pokemon__name"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>{pokemon.name}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"pokemon__meta"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>{pokemon.maxHP}<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>{pokemon.maxCP}<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"pokemon__image"</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">{pokemon.image}</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">{pokemon.name}</span> /&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"pokemon__attacks"</span>&gt;</span>
        {pokemon.attacks.special.slice(0, 3).map((attack) =&gt; (
          <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{</span>`${<span class="hljs-attr">attack.name</span>}<span class="hljs-attr">-</span>${<span class="hljs-attr">attack.damage</span>}`}&gt;</span>{attack.name}<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
        ))}
      <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}
</code></pre>
<p>The structure of an instance of a Pokemon is defined here with the classname for styling. The <code>name</code>, <code>maxHP</code>, <code>maxCP</code>, <code>image</code> and <code>attacks</code> array will be rendered.</p>
<p>Let's create the <code>GET_POKEMONS</code> GraphQL query.</p>
<p>📂src/graphql/get-pokemons</p>
<h2 id="heading-graphql-query">GraphQL Query</h2>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> gql <span class="hljs-keyword">from</span> <span class="hljs-string">"graphql-tag"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> GET_POKEMONS = gql<span class="hljs-string">`
  query pokemons($first: Int!) {
    pokemons(first: $first) {
      id
      name
      image
      maxHP
      maxCP
      attacks {
        special {
          name
          damage
        }
      }
    }
  }
`</span>;
</code></pre>
<p>You imported <code>gql</code> from <code>graphql-tag</code> and created a GraphQL query named <code>GET_POKEMONS</code>.</p>
<p>The <code>pokemons</code> query function was wrapped in strings for the <code>gql</code> function to parse them into query documents.</p>
<p><code>$first: Int!</code> means that your query is expecting a variable called <code>first</code>, which is an integer, and the <code>!</code> symbol after the <code>Int</code> means that the variable is required.</p>
<p>Recall that we created the <code>variables</code> object in the <code>PokemonsContainer</code> component, it's here below.</p>
<pre><code class="lang-javascript"> <span class="hljs-keyword">const</span> { loading, error, data } = useQuery(GET_POKEMONS, {
   <span class="hljs-attr">variables</span>: { <span class="hljs-attr">first</span>: <span class="hljs-number">5</span> },
 });
</code></pre>
<p><code>pokemons(first: $first)</code> was also declared. <code>$first</code> will be assigned to 5 here (we passed in 9 in the above code snippet). Thus, the array will contain only 5 objects. Each object will contain <code>id</code>, <code>name</code>, <code>image</code>, <code>maxHP</code>, <code>maxCP</code>, and attacks object which will contain the special object containing name and damage.</p>
<p>The GraphQL server might contain more properties but will only return the properties listed above. That is one of the cool functionalities of GraqhQL – it gives you only the data you request for.</p>
<h2 id="heading-styling-our-application">Styling our Application</h2>
<p>Your <strong>index.css</strong> should contain this:</p>
<pre><code class="lang-css"><span class="hljs-comment">/* RESETS
=========================================== */</span>
<span class="hljs-selector-tag">html</span> {
  <span class="hljs-attribute">-webkit-box-sizing</span>: border-box;
  <span class="hljs-attribute">box-sizing</span>: border-box;
}

*,
*<span class="hljs-selector-pseudo">:before</span>,
*<span class="hljs-selector-pseudo">:after</span> {
  <span class="hljs-attribute">-webkit-box-sizing</span>: inherit;
  <span class="hljs-attribute">box-sizing</span>: inherit;
}

<span class="hljs-selector-tag">body</span> {
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">20px</span> <span class="hljs-number">0</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span> <span class="hljs-number">20px</span>;
  <span class="hljs-attribute">line-height</span>: <span class="hljs-number">1</span>;
  <span class="hljs-attribute">font-family</span>: <span class="hljs-string">"Segoe UI"</span>, Tahoma, Geneva, Verdana, sans-serif;
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#202020</span>;
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#fbfbfb</span>;
  <span class="hljs-attribute">font-smooth</span>: always;
  <span class="hljs-attribute">-webkit-font-smoothing</span>: antialiased;
  <span class="hljs-attribute">-moz-osx-font-smoothing</span>: grayscale;
}

<span class="hljs-comment">/* POKEMON APPLICATION
=========================================== */</span>
<span class="hljs-selector-class">.container</span> {
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">max-width</span>: <span class="hljs-number">80%</span>;
  <span class="hljs-attribute">margin</span>: auto;
  <span class="hljs-attribute">height</span>: <span class="hljs-number">100vh</span>;
  <span class="hljs-attribute">justify-content</span>: space-between;
  <span class="hljs-attribute">align-items</span>: center;
  <span class="hljs-attribute">gap</span>: <span class="hljs-number">10px</span>;
}

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
}

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.pokemon</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">20%</span>;
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#fff</span>;
  <span class="hljs-attribute">background-clip</span>: border-box;
  <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <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.125</span>);
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">0.25rem</span>;
  <span class="hljs-attribute">box-shadow</span>: <span class="hljs-number">0</span> <span class="hljs-number">0.125rem</span> <span class="hljs-number">0.25rem</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.075</span>);
  <span class="hljs-attribute">overflow</span>: hidden;
  <span class="hljs-comment">/* margin: 5px; */</span>
}

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.pokemon__name</span> {
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#ecd018</span>;
  <span class="hljs-attribute">text-align</span>: center;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">10px</span>;
}

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.pokemon__name</span> <span class="hljs-selector-tag">p</span> {
  <span class="hljs-attribute">text-transform</span>: uppercase;
  <span class="hljs-attribute">font-weight</span>: bold;
  <span class="hljs-attribute">color</span>: white;
  <span class="hljs-attribute">letter-spacing</span>: <span class="hljs-number">4px</span>;
  <span class="hljs-attribute">text-shadow</span>: <span class="hljs-number">0px</span> <span class="hljs-number">1px</span> <span class="hljs-number">2px</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.4</span>);
}

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.pokemon__image</span> {
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">20px</span>;
  <span class="hljs-attribute">min-height</span>: <span class="hljs-number">300px</span>;
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">align-items</span>: center;
  <span class="hljs-attribute">justify-content</span>: center;
}

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

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.pokemon__attacks</span> {
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">padding-left</span>: <span class="hljs-number">10px</span>;
  <span class="hljs-attribute">padding-right</span>: <span class="hljs-number">10px</span>;
  <span class="hljs-attribute">justify-content</span>: space-between;
}

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.pokemon__attacks</span> <span class="hljs-selector-tag">span</span> {
  <span class="hljs-attribute">width</span>: <span class="hljs-number">32%</span>;
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#f16820</span>;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">3px</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">7px</span>;
  <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">700</span>;
  <span class="hljs-attribute">color</span>: <span class="hljs-number">#fff</span>;
  <span class="hljs-attribute">padding-left</span>: <span class="hljs-number">10px</span>;
  <span class="hljs-attribute">padding-right</span>: <span class="hljs-number">10px</span>;
  <span class="hljs-attribute">font-size</span>: <span class="hljs-number">12px</span>;
  <span class="hljs-attribute">margin-bottom</span>: <span class="hljs-number">10px</span>;
  <span class="hljs-attribute">word-wrap</span>: break-word;
  <span class="hljs-attribute">text-align</span>: center;
  <span class="hljs-attribute">line-height</span>: <span class="hljs-number">15px</span>;
}

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.pokemon__meta</span> {
  <span class="hljs-attribute">display</span>: flex;
  <span class="hljs-attribute">justify-content</span>: space-between;
  <span class="hljs-attribute">margin-top</span>: <span class="hljs-number">10px</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span> <span class="hljs-number">10px</span>;
}

<span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.pokemon__meta</span> <span class="hljs-selector-tag">span</span> {
  <span class="hljs-attribute">color</span>: white;
  <span class="hljs-attribute">text-shadow</span>: <span class="hljs-number">0px</span> <span class="hljs-number">1px</span> <span class="hljs-number">2px</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.4</span>);
  <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#7bb7b7</span>;
  <span class="hljs-attribute">font-weight</span>: bold;
  <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
  <span class="hljs-attribute">padding</span>: <span class="hljs-number">5px</span> <span class="hljs-number">20px</span>;
  <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">5px</span>;
}
</code></pre>
<p>All things done right, you should have this in your browser:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1712103327205/94a0fc27-6e6e-4441-b7e7-c3e3df005383.png" alt="Image" width="600" height="400" loading="lazy">
<em>a picture showing the five pokemons data in the browser</em></p>
<p>You can get the GitHub code here: <a target="_blank" href="https://github.com/segunajibola/pokemon-graphql">https://github.com/segunajibola/pokemon-graphql</a></p>
<p>You can also view the live site hosted on Vercel here: <a target="_blank" href="http://pokemonsapp.vercel.app"><strong>pokemonsapp.vercel.app</strong></a></p>
<p>Check my portfolio of projects: <a target="_blank" href="https://segunajibola.com">segunajibola.com</a></p>
<h2 id="heading-conclusionhttpspokemonsappvercelapp"><a target="_blank" href="https://pokemonsapp.vercel.app/">Conclusion</a></h2>
<p>That will be all. I hope you found value here as you learn more about the web.</p>
<p>If you enjoyed this article and want to see more content related to JavaScript and web development, then follow me here, <a target="_blank" href="https://x.com/intent/follow?screen_name=iamsegunajibola">Twitter (X)</a> or connect on <a target="_blank" href="https://www.linkedin.com/mwlite/in/segun-ajibola-511502175">LinkedIn</a>. I'd be happy to count you as one of my ever-growing group of awesome friends on the internet.</p>
<p>You can also join my <a target="_blank" href="https://chat.whatsapp.com/E57KqFYQK9B1woySXTaqKr">WhatsApp developer community</a> and <a target="_blank" href="https://chat.whatsapp.com/KH7r2EA6kMgHuHwVfM4VFB">OpenSource community</a> of 330+ developers learning and building cool projects.</p>
<p>If you also want to support me, you can also <a target="_blank" href="https://www.buymeacoffee.com/segunajibola">buy me a cup of coffee</a>.</p>
<p>Thanks and bye. 👋</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Setup React and Tailwind CSS with Vite in a Project ]]>
                </title>
                <description>
                    <![CDATA[ Tailwind CSS is a popular CSS framework, and React is one of the most popular JavaScript libraries. And Tailwind CSS and React are a great combo to use if you're building a frontend project. In this article, you will learn how to setup your coding en... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-install-tailwindcss-in-react/</link>
                <guid isPermaLink="false">66c8c94cc4cede4e0083f73b</guid>
                
                    <category>
                        <![CDATA[ CSS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tailwind ]]>
                    </category>
                
                    <category>
                        <![CDATA[ vite ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Segun Ajibola ]]>
                </dc:creator>
                <pubDate>Mon, 09 Jan 2023 18:49:56 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/Parameters-vs-Arguments--1-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Tailwind CSS is a popular CSS framework, and React is one of the most popular JavaScript libraries.</p>
<p>And Tailwind CSS and React are a great combo to use if you're building a frontend project.</p>
<p>In this article, you will learn how to setup your coding environment with Vite, install React and Tailwind CSS with their latest versions, and start building your projects right away.</p>
<p>We will be using these tools:</p>
<ul>
<li><a target="_blank" href="https://code.visualstudio.com/download">VSCode</a> for our code editor</li>
<li><a target="_blank" href="https://nodejs.org/en/download/">Node.js</a> for our package manager</li>
<li><a target="_blank" href="https://vitejs.dev/">Vite</a> for our development environment</li>
</ul>
<p>If you don't have these tools installed, you can do so by clicking the links for each one above.</p>
<p>After setting up Node.js for your VSCode, you can now use Node.js to install Vite for your project using the terminal.</p>
<h2 id="heading-step-1-create-your-project-folder">Step 1 – Create Your Project Folder</h2>
<p>Open your terminal, and navigate to the folder where you want to build your project – for example Desktop. Input the command below in the terminal and click <code>enter</code>:‌</p>
<pre><code class="lang-node.js">npm create vite@latest your-project-name -- --template react
</code></pre>
<p>The command above will create your project folder.‌</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-03-000708.png" alt="My project name is &quot;food-app&quot;, the food-app folder will be created in the Programming folder on my Desktop" width="600" height="400" loading="lazy">
<em>My project name is "food-app", the food-app folder will be created in the Programming folder on my Desktop</em></p>
<p>‌Note that we have used <code>-- --template react</code> to specify that we are building a React app with Vite.</p>
<h2 id="heading-step-2-navigate-to-your-project-folder">Step 2 – Navigate to Your Project Folder</h2>
<p>Input the command below in your terminal and click <code>enter</code>:</p>
<pre><code class="lang-shell">cd food-app
</code></pre>
<p>‌This command will navigate to your project folder. You should have this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-03-001414.png" alt="Inputing &quot;cd food-app&quot; in terminal to navigate to the &quot;food-app&quot; folder" width="600" height="400" loading="lazy">
<em>Inputing "cd food-app" in terminal to navigate to the "food-app" folder</em></p>
<h2 id="heading-step-3-install-tailwind-css-and-other-dependencies"><strong>Step 3 – Install Tailwind CSS and Other Dependencies</strong></h2>
<p>Input the command below in your terminal and click <code>enter</code>:</p>
<pre><code class="lang-node">npm install -D tailwindcss postcss autoprefixer
</code></pre>
<p>This command will install the following:</p>
<ul>
<li>The Tailwind CSS framework</li>
<li>Post CSS, which provides plugins to perform different functionalities like prefixes in Vanilla CSS</li>
<li>Autoprefixer, which is a PostCSS plugin to parse CSS and add vendor prefixes to CSS rules.</li>
</ul>
<p>Your folder should look like this in your VSCode:‌</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-03-004354.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Confirm that you have the below text in your <code>package.json</code>‌:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-03-004416.png" alt="Image" width="600" height="400" loading="lazy">
<em></em></p><div id="ember183" class="miw-100 tc bn form-text bg-transparent pr8 pl8 ember-view" data-kg-has-link-toolbar="true" data-koenig-dnd-disabled="true"><div class="koenig-basic-html-input__editor-wrappper"><div class="koenig-basic-html-input__editor __mobiledoc-editor" data-gramm="false" data-kg="editor" data-kg-allow-clickthrough="" data-placeholder="Type caption for image (optional)"><p><em>Notice the autoprefixer, postcss and tailwindcss dependencies from line 19 - 21. The version number might have changed when you read this.</em></p></div></div></div><p></p>
<h2 id="heading-step-4-generate-the-configuration-files">Step 4 – Generate the Configuration Files</h2>
<p>Input the command below in your terminal and click <code>enter</code>:</p>
<pre><code class="lang-node">npx tailwindcss init -p
</code></pre>
<p>This command generates <code>tailwind.config.cjs</code> and<code>postcss.config.cjs</code> configuration files, also known as config files. They help you interact with your project and customize everything.</p>
<h2 id="heading-step-5-configure-source-paths">Step 5 – Configure Source Paths</h2>
<p>Add the paths to all of your template files in your <code>tailwind.config.cjs</code> file. Template files include HTML templates, JavaScript components, and other source files that contain Tailwind class names. This is to make sure that vanilla CSS is generated for the corresponding elements.</p>
<p>Your <code>tailwind.config.cjs</code> looks like this for now:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-03-235907.png" alt="Current config file named as tailwind.config.cjs, it contains module.export object to customize tailwind with property like content, theme and plugins" width="600" height="400" loading="lazy">
<em>Current config file named as tailwind.config.cjs, it contains the module.export object to customize tailwind with property like content, theme and plugins</em></p>
<p>Add this in your content section.</p>
<pre><code class="lang-json"><span class="hljs-string">"./index.html"</span>,


<span class="hljs-string">"./src/**/*.{js,ts,jsx,tsx}"</span>,
</code></pre>
<p>So your file should now look like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-04-000648.png" alt="config file after updating the content property" width="600" height="400" loading="lazy">
<em>Config file after updating the content property</em></p>
<h2 id="heading-step-6-add-tailwind-directives-to-your-css"><strong>Step 6 – Add Tailwind Directives to Your CSS</strong></h2>
<p>Tailwind directives are custom Tailwind-specific statements that instruct CSS how to behave. You'll need to add directives for three of Tailwind’s layers. </p>
<p><code>@tailwind base</code> injects Tailwind's base styles and base styles registered by plugins, <code>@tailwind components</code> injects Tailwind's component classes and component classes registered by plugins, while <code>@tailwind utilities</code> injects Tailwind's utility classes and utility classes registered by plugins.</p>
<p>Add the statements below to your <code>./src/index.css</code> file:</p>
<pre><code class="lang-css"><span class="hljs-keyword">@tailwind</span> base;
<span class="hljs-keyword">@tailwind</span> components;
<span class="hljs-keyword">@tailwind</span> utilities;
</code></pre>
<pre><code class="lang-css"><span class="hljs-keyword">@tailwind</span> base;
<span class="hljs-keyword">@tailwind</span> components;
<span class="hljs-keyword">@tailwind</span> utilities;
</code></pre>
<p>Your <code>index.css</code> file contains some default styling. You can clear all that and paste the three lines of directives above.</p>
<h2 id="heading-step-7-start-your-vite-server">Step 7 – Start Your Vite Server</h2>
<p>Run your build process with the <code>npm run dev</code> command in the terminal. You should get this message below in your terminal‌:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-04-005534.png" alt="The message you get after running your Vite server that provides localhost link, network and help." width="600" height="400" loading="lazy">
<em>The message you get after running your Vite server that provides localhost link, network, and help.</em></p>
<p>Hold the <code>ctrl</code> key and click on the link at Local – here it's http://127.0.0.1:5174. It will open a new tab in your browser if you do that.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-04-005850.png" alt="A screenshot of the webpage on first run" width="600" height="400" loading="lazy">
<em>A screenshot of the webpage on first run</em></p>
<p>Our styles are broken because we cleared the default CSS in the <code>index.css</code> file to input our directives.</p>
<h2 id="heading-step-8-start-writing-tailwind-css">Step 8 – Start Writing Tailwind CSS</h2>
<p>You can start using Tailwind’s utility classes to style your content. Navigate to your <code>App.jsx</code> file, where you should see this below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-04-184158.png" alt="Screenshot of the App.jsx file" width="600" height="400" loading="lazy">
<em>Screenshot of the App.jsx file</em></p>
<p>Clear the return element starting from line 9, and replace it with the text below to test your Tailwind to know if it is working. Input this:</p>
<pre><code class="lang-jsx">&lt;h1 className=<span class="hljs-string">"text-3xl font-bold underline text-center"</span>&gt;Hello world!&lt;/h1&gt;
</code></pre>
<p>Now you have this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-04-184804.png" alt="Adding the h1 element to the App.jsx file with tailwindcss styles applied" width="600" height="400" loading="lazy">
<em>Adding the h1 element to the App.jsx file</em></p>
<p>According to the above image, <code>text-3xl font-bold text-red-500 underline text-center</code> has been added as a className to the <code>div</code> element. This is the standard for writing Tailwind CSS styling.</p>
<p>You can learn more about Tailwind classnames <a target="_blank" href="https://tailwindcss.com/docs/">here</a>. Your browser should update automatically.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/Screenshot-2023-01-04-184720.png" alt="Screenshot of the webpage after add the h1 element, showing Hello World with tailwind CSS styles applied." width="600" height="400" loading="lazy">
<em>Screenshot of the webpage after add the h1 element</em></p>
<p>You can now start building your React projects and style them with Tailwind CSS.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>You have now created a React and Tailwind CSS app using Vite, a frontend build tool. You have learned what Vite is and how to create a Vite app with a React template, as well as how to install Tailwind and other dependencies.</p>
<p>Thanks for reading this article. If you enjoyed it, consider sharing it to help other developers.</p>
<p>You can reach me on <a target="_blank" href="https://twitter.com/iamsegunajibola">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/segunajibola/">LinkedIn</a> and <a target="_blank" href="https://github.com/segunajibola">GitHub</a>.</p>
<p>Happy Learning.‌</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Parameters vs Arguments in JavaScript – What's the Difference? ]]>
                </title>
                <description>
                    <![CDATA[ JavaScript is one of the most popular programming languages out there for web development. The dynamic values passed in a JavaScript function can change when the function gets called in another location in the code. The keywords we use to name these ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-is-the-difference-between-parameters-and-arguments-in-javascript/</link>
                <guid isPermaLink="false">66c8c952073b3e2196fec38c</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Segun Ajibola ]]>
                </dc:creator>
                <pubDate>Wed, 28 Sep 2022 21:18:15 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/09/Parameters-vs-Arguments.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>JavaScript is one of the most popular programming languages out there for web development.</p>
<p>The dynamic values passed in a JavaScript function can change when the function gets called in another location in the code. The keywords we use to name these data are parameters and arguments, but some developers confuse them.</p>
<p>In this article, you will learn about parameters and arguments and what they are, along with where and when to use them.</p>
<h3 id="heading-table-of-contents">Table of Contents</h3>
<ul>
<li>Introduction to JavaScript functions</li>
<li>How to use Parameters and Arguments in a function</li>
<li>The power of arguments</li>
<li>Conclusion</li>
</ul>
<h2 id="heading-introduction-to-javascript-functions">Introduction to JavaScript Functions</h2>
<p>One of the fundamental building blocks in JavaScript programming is a function. It's a block of code designed to perform a particular task.</p>
<p>Functions are reusable code which you can use anywhere in your program. They eliminate the need to repeat the same code all the time.</p>
<p>To use functions in a powerful way, you can pass values in a function to use them.</p>
<p>Here is an example of a function:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params"></span>)</span>{
    <span class="hljs-keyword">return</span> <span class="hljs-number">2</span> + <span class="hljs-number">3</span>
}

add()
</code></pre>
<p>This is a function declaration, the name of the function is <code>add</code>, and it was called after the function with <code>add()</code> . The result of the function will be 5.</p>
<p>Let's introduce parameters and arguments in the function.</p>
<h2 id="heading-how-to-use-parameters-and-arguments-in-a-function">How to Use Parameters and Arguments in a Function</h2>
<p>Take a look at our function code now:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">x, y</span>)</span>{
    <span class="hljs-keyword">return</span> x + y
}

add(<span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
</code></pre>
<p>We have introduced x and y here and changed the location of the 2 and 3. x and y are the parameters while 2 and 3 are the arguments here.</p>
<p>A <strong>parameter</strong> is one of the variables in a function. And when a method is called, the <strong>arguments</strong> are the data you pass into the method's parameters.</p>
<p>When the function is called with <code>add(2, 3)</code> the arguments 2 and 3 are assigned to x and y, respectively. This means that in the function, x will be replaced with 2 and y will be replaced with 3.</p>
<p>If the function is called with a different argument, the same applies. Parameters are like placeholders for function arguments.</p>
<h2 id="heading-the-power-of-arguments">The Power of Arguments</h2>
<p>We can use arguments more efficiently when we want to make functions more re-useable, or when we want to make calling functions inside another functions more powerful.</p>
<p>Here is an example:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">x, y</span>)</span>{
    <span class="hljs-keyword">return</span> x + y
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">multiply</span>(<span class="hljs-params">a, b, c</span>)</span>{ <span class="hljs-comment">// a = 1, b = 2, c = 3</span>
    <span class="hljs-keyword">const</span> num1 = add(a, b) <span class="hljs-comment">// num1 = add(1, 2) = 3</span>
    <span class="hljs-keyword">const</span> num2 = add(b, c) <span class="hljs-comment">// num2 = add(2, 3) = 5</span>

    <span class="hljs-keyword">return</span> num1 * num2 <span class="hljs-comment">// 15</span>
}

multiply(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
<span class="hljs-comment">// returns 15</span>
</code></pre>
<p>The first function <code>add()</code> has two parameters, x and y. The function returns the addition of the two parameters.</p>
<p>The second function <code>multiply()</code> has three parameters: inside the function, two variables are declared in it, <code>num1</code> and <code>num2</code>. <code>num1</code> will store the value of the result of <code>add(a, b)</code>, and <code>num2</code> will store the value of the result of <code>add(b, c)</code>. At the end the <code>multiply</code> function will return the value of <code>num1</code> multiplied by <code>num2</code>.</p>
<p><code>multiply</code> is called with three arguments which are 1, 2 and 3. <code>add(a, b)</code> will be <code>add(1, 2)</code> which will return 3. <code>add(b, c)</code> will be <code>add(2, 3)</code> which will return 5.</p>
<p><code>num1</code> will have the value of 3 while <code>num2</code> will be 5. <code>num1 * num2</code> will return 15.</p>
<p>Arguments are passed in the <code>multiply</code> function which are also used as arguments for the <code>add</code> function.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Using parameters and arguments can be confusing at times, especially if you are just learning them. But if you first properly learn what a function is and how it works, you will understand parameters and arguments easily.</p>
<p>Thanks for reading this article. If you enjoyed it, consider sharing it to help other developers.</p>
<p>You can reach me on <a target="_blank" href="https://twitter.com/iamsegunajibola">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/segunajibola/">LinkedIn</a> and <a target="_blank" href="https://github.com/segunajibola">GitHub</a>.</p>
<p>Happy Learning.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use Git and GitHub – Introduction for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ Git and GitHub are common tools used in programming. They help you manage different versions of your code and collaborate with other developers. Building projects is one of the core parts of being a developer. And Git and GitHub are essential tools y... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/introduction-to-git-and-github/</link>
                <guid isPermaLink="false">66c8c94f35adc35234e1f4d3</guid>
                
                    <category>
                        <![CDATA[ beginners guide ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Git ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ version control ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Segun Ajibola ]]>
                </dc:creator>
                <pubDate>Mon, 26 Sep 2022 05:23:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/09/Untitled-design--6-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Git and GitHub are common tools used in programming. They help you manage different versions of your code and collaborate with other developers.</p>
<p>Building projects is one of the core parts of being a developer. And Git and GitHub are essential tools you'll use when building projects with others.</p>
<p>But they can look complicated if you haven't used them before. So I wrote this article to simplify how Git and GitHub work.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><a class="post-section-overview" href="#heading-what-are-git-and-github">What are Git and GitHub</a>?</li>
<li><a class="post-section-overview" href="#heading-why-should-you-learn-git-and-github">Why should you learn Git and GitHub</a>?</li>
<li><a class="post-section-overview" href="#heading-differences-between-git-and-github">Differences between Git and GitHub</a></li>
<li><a class="post-section-overview" href="#heading-how-to-start-using-git-and-github">How to start using Git and GitHub</a></li>
<li><a class="post-section-overview" href="#resouces-to-learn-git-and-github">Resources to learn Git and GitHub</a></li>
</ul>
<h2 id="heading-what-are-git-and-github">What are Git and GitHub?</h2>
<p>Git was developed in 2005 by Linus Torvalds as <em>open source software</em> for tracking changes in a <em>distributed version control system</em>.</p>
<p>Git is open source because its source code is made freely available for anyone to modify and use, aside from its creator. Open-source projects are built and maintained collectively by different developers in different locations.</p>
<p>Git track changes via a distributed version control system. This means that Git can track the state of different versions of your projects while you're developing them. It is distributed because you can access your code files from another computer – and so can other developers.</p>
<p>When you're building an open source project, you'll need a way to document or track your code. This helps make your work organized, and lets you keep track of the changes you've made. This is what Git lets you do.</p>
<p>But you also need a place to host your code – which makes controlling each version of your project easier and faster. This is where GitHub comes in.</p>
<p>GitHub is a "hub" (a place or platform) where Git users build software together. GitHub is also an hosting provider and version control platform you can use to collaborate on open source projects and share files. When you're using GitHub, you're working with Git beneath the hood.</p>
<h2 id="heading-why-should-you-learn-git-and-github">Why Should You Learn Git and GitHub?</h2>
<p>According to Techmonitor.ai, over 73 million developers use GitHub as of November 2021. And the GitHub community is set to hit 100 million users by 2025.</p>
<p>As you can see, millions of people all over the world use these tools, and the numbers just keep going up.</p>
<p>Because of this, more companies are requiring new hires to know how to use Git and GitHub. So if you're looking for a developer job, these are essential skills to have.</p>
<p>If you're not using Git and GitHub, it's clear – you should be!</p>
<h2 id="heading-differences-between-git-and-github">Differences between Git and GitHub</h2>
<p>Git is a version control system that manages and keeps track of your code. GitHub, on the other hand, is a service that let you host, share, and manage your code files on the internet.</p>
<p>GitHub uses Git underneath, and lets you manage your Git repositories or folders easily on its platform.</p>
<p>So Git is the actual version control system and GitHub is the platform where you host your code.</p>
<p>If you want to learn more about the differences between these two tools, you can <a target="_blank" href="https://www.freecodecamp.org/news/git-and-github-overview/">read this tutorial</a>.</p>
<h2 id="heading-how-to-start-using-git-and-github">How to Start Using Git and GitHub</h2>
<h3 id="heading-step-1-install-git">Step 1 – Install Git</h3>
<p>Git comes preinstalled in some Macs and Linux-based systems, but you can always check if you have Git installed in your machine by typing <code>git version</code> in your terminal. You can use the Command Prompt to do this.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/checkGItInstalled-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>As you can see above, I have Git version 2.31.1 installed on my Windows computer. If you don't have Git installed in your computer, you won't get a version.</p>
<p>You can download Git <a target="_blank" href="https://git-scm.com/download">here</a> and then select your operating system to download.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/gitDownload-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Follow the necessary installer guide until installation is complete. Open the command prompt and type <code>git version</code> to verify that Git was successfully installed.</p>
<h3 id="heading-step-2-create-a-github-account">Step 2 – Create a GitHub Account.</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/githubDownload-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>To create an account on GitHub, you will be asked for some personal information like name, confirm your email, set a username and password, and your account should be set up in minutes.</p>
<p>Create an account on <a target="_blank" href="https://github.com/">GitHub.com here</a>.</p>
<h3 id="heading-step-3-connect-your-github-account-to-your-git-account">Step 3 – Connect your GitHub account to your Git account.</h3>
<p>You'll do this from your terminal.</p>
<p>To set your Git username, type this in your terminal:</p>
<pre><code class="lang-shell">git config --global user.name "Segun Ajibola"
</code></pre>
<p>To confirm that you have set your Git username correctly, type this:</p>
<pre><code class="lang-shell">git config --global user.name
</code></pre>
<p>You should have "Segun Ajibola" as the output. </p>
<p>To set your Git email, type this in your terminal:</p>
<pre><code class="lang-shell">git config --global user.email "youremail@gmail.com"
</code></pre>
<p>To confirm that you have set your Git email correctly, type this:</p>
<pre><code class="lang-shell">git config --global user.email
</code></pre>
<p>You should have "youremail@gmail.com" as the output. </p>
<p>You will be asked to authenticate your GitHub account, so just sign in with the same email to confirm.</p>
<h3 id="heading-step-4-create-and-edit-your-code-files-locally">Step 4 – Create and edit your code files locally</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/codeFIles-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-step-5-create-a-repository-on-github">Step 5 – Create a repository on GitHub</h3>
<p>Click the + sign at the top right corner to create a new repository. Repositories are like your code folders online.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/newRepo-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You will be prompted to this page:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/newRepo2-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/newRepo3-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Name your repository and give it a description (this is optional).</p>
<p>Click the "Create repository" button to create the repository. You will be prompted to this page:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/newRepoGitHub-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-step-6-push-your-local-code-to-github">Step 6 – Push your local code to GitHub</h3>
<p>You can use the code editor built-in terminal to use Git to push your code to GitHub. Click <code>ctrl</code> + <code>shift</code> + <code>'</code> to open the terminal in VSCode.</p>
<p>Input the commands below one after the other in your terminal. Press the <code>Enter</code> key to proceed after every input.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/pushCode-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>‌<code>echo "# sample-code" &gt;&gt; README.md</code> </p>
<p><code>git init</code></p>
<p><code>git add .</code></p>
<p><code>git commit -m "first commit"</code></p>
<p><code>git branch -M main</code></p>
<p><code>git remote add origin https://github.com/segunajibola/sample-code.git</code></p>
<p><code>git push -u origin main</code> </p>
<p>Note that we have <code>git add README.md</code>  in the repository on GitHub. But here we have <code>git add .</code>, which is to let Git add all our code files instead of the <code>README.md</code> file which will be created by <code>echo "# sample-code" &gt;&gt; README.md</code>. So if you have created other files in your local folder, you need to use <code>git add .</code> to add all files.</p>
<p>Take note that <code>git remote add origin [https://github.com/segunajibola/sample-code.git](https://github.com/segunajibola/sample-code.git)</code> will contain the link to your own repository and it will have have the name of your GitHub account.</p>
<h2 id="heading-common-git-commands-to-know">Common Git Commands to Know</h2>
<p>They are many Git commands you can use in the terminal, and that can get overwhelming. So I'd suggest focusing on some of the most popular ones first. </p>
<p>Here they are:</p>
<p><code>git init</code> lets you initialize Git in your folder.</p>
<p><code>git add [Readme.md](https://readme.md/)</code> lets you add the Readme file, while <code>git add .</code> lets you add all files in the present folder.</p>
<p><code>git commit</code> stores the added files. Use <code>-m</code> for message followed by the actual message.</p>
<p><code>git branch</code> creates a new branch which is a new version of the repository as it appears when added, and <code>-M</code> to move the name to <code>main</code>.</p>
<p><code>git remote add origin</code> finally connects the local folder to the repository on GitHub. It is followed by the repository's link.</p>
<p><code>git push -u origin main</code> pushes the code to GitHub. The <code>-u</code> flag creates a tracking reference for the branch, and <code>origin main</code> puts the code in the <code>main</code> branch.</p>
<p>Those are some of the main commands you'll use all the time. This is a beginner and non-technical guide to help you get started using Git and GitHub, so we won't go into too much more detail here.</p>
<p>The more you continue using GitHub, the more comfortable you'll get using these commands. The key is to start small and maintain your momentum.</p>
<p>It will eventually get easier as you build small projects and host them on GitHub using Git.</p>
<p>If you find it hard to use the terminal to navigate between folders, spend some time to practice with it. Again, it gets easier with time and use.</p>
<h2 id="heading-how-to-customize-your-github-profile">How to Customize Your GitHub Profile</h2>
<p>Customizing your GitHub profile README helps you stand out from random GitHub users.</p>
<p>The README.md file helps you describe your GitHub profile, and you can use it to show what you're currently learning along with your skills and contributions.</p>
<p>The GitHub README.md uses markdown to format its content. It has an easy-to-learn syntax.</p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/how-to-write-a-good-readme-file/">Here</a> is a simple guide to create and customize your GitHub account.</p>
<p>Here is my GitHub profile's README.md file.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/GithubReadme1-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/GithubReadme2-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/GithubReadme3-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/GithubReadme4-1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can check out some other GitHub README.md personalized profiles <a target="_blank" href="https://github.com/abhisheknaiidu/awesome-github-profile-readme">here</a>.</p>
<h2 id="heading-resources-to-learn-git-and-github">Resources to learn Git and GitHub</h2>
<p>Here are some helpful courses and articles you can go through if you want to learn Git and GitHub in more detail:</p>
<ol>
<li><a target="_blank" href="https://www.freecodecamp.org/news/git-and-github-for-beginners/">Git and GitHub Tutorial – Version Control for Beginners</a></li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/how-to-use-basic-git-and-github-commands/">Basic Git Commands – How to Use Git in a Real Project</a></li>
<li><a target="_blank" href="https://www.youtube.com/watch?v=RGOj5yH7evk">Git and GitHub for Beginners - Crash Course</a></li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/what-is-git-and-how-to-use-it-c341b049ae61/">An introduction to Git: what it is, and how to use it</a></li>
<li><a target="_blank" href="https://github.com/about">About GitHub</a></li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>If you have finished reading this, you might be feeling overwhelmed about Git and GitHub. Yes it's another big thing you need to learn in tech, but do not fret.</p>
<p>Remember that whenever you start learning something new, at first it can seem like you won't get the hang of it. But after some time and hard work, you'll become more comfortable.</p>
<p>It's the same with Git and GitHub too – if you use it a lot for a while, you will get comfortable with it.</p>
<p>Thanks for reading this article. If you enjoyed it, consider sharing it to help other developers.</p>
<p>You can reach me on <a target="_blank" href="https://twitter.com/iamsegunajibola">Twitter</a>, <a target="_blank" href="https://www.linkedin.com/in/segunajibola/">LinkedIn</a> and <a target="_blank" href="https://github.com/segunajibola">GitHub</a>.</p>
<p>Happy Learning.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
