<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Akeem Qudus I</title>
    <description>The latest articles on Forem by Akeem Qudus I (@js_lover).</description>
    <link>https://forem.com/js_lover</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1004064%2Fc416ebd5-28fb-42fa-a415-57054ec35c21.jpeg</url>
      <title>Forem: Akeem Qudus I</title>
      <link>https://forem.com/js_lover</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/js_lover"/>
    <language>en</language>
    <item>
      <title>Implementing GitHub content API with custom hook &amp; Context API</title>
      <dc:creator>Akeem Qudus I</dc:creator>
      <pubDate>Tue, 10 Jan 2023 12:24:09 +0000</pubDate>
      <link>https://forem.com/js_lover/implementing-github-content-api-with-custom-hook-context-api-4ekk</link>
      <guid>https://forem.com/js_lover/implementing-github-content-api-with-custom-hook-context-api-4ekk</guid>
      <description>&lt;p&gt;As a student of AltSchool of Africa willing and working towards making it to the end of the end of the program, we were given exam project to execute as criteria to pass second semester to the third semester. Out of for questions I choose: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Implement an API fetch of your GitHub portfolio, show a page with a list of all your repositories on GitHub(the page should implement pagination for the repo list), and create another page showing data for a single repo clicked from the list of repos using nested routes while using all the necessary tools in react. Implement the proper SEO, Error Boundary (show a page to test the error boundary) and 404 pages. Good UI and Designs are important.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this article, I will be taking you through how you can build and implement every technology I used in the course of executing this task. In the course of trying to build the project the following technology were implemented:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;React Router&lt;/li&gt;
&lt;li&gt;React Hook&lt;/li&gt;
&lt;li&gt;Custom hook (useFetch)&lt;/li&gt;
&lt;li&gt;Fetch&lt;/li&gt;
&lt;li&gt;Client Side Pagination&lt;/li&gt;
&lt;li&gt;Context API&lt;/li&gt;
&lt;li&gt;Error Boundary&lt;/li&gt;
&lt;li&gt;React Helmet (SEO)&lt;/li&gt;
&lt;li&gt;Netlify Hosting&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;p&gt;To get started or be able to follow along, you need to have the following installed on your machine (computer):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node ([&lt;a href="https://nodejs.org/en/download/%5D" rel="noopener noreferrer"&gt;https://nodejs.org/en/download/]&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;VS Code ([&lt;a href="https://code.visualstudio.com/download%5D" rel="noopener noreferrer"&gt;https://code.visualstudio.com/download]&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You will also need to have an account on GitHub and Netlify as we'll be needing it for hosting&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up React App
&lt;/h2&gt;

&lt;p&gt;In every react application, the very first thing to do is to install react. Open up your terminal, navigate to where you want to have your project. Follow the following steps to set up your App.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run: &lt;code&gt;npx create-react-app my-app&lt;/code&gt; (my-app here could be anything you wish to name your project)&lt;/li&gt;
&lt;li&gt;After installing, run &lt;code&gt;cd my-app&lt;/code&gt; (your app name)&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;code .&lt;/code&gt; to open your App in VS Code. Your folder tree should look like the picture below:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wdxcqro3d6yy4hajfnk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wdxcqro3d6yy4hajfnk.png" alt="Image description" width="318" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s do a little bit of house cleaning, we will be deleting some files we don’t need, this isn’t compulsory, it is just something I do. Delete some files to make your folder tree look exactly like the picture below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5cyye2g8owzu6736ss5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5cyye2g8owzu6736ss5.png" alt="Image description" width="362" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the root component &lt;em&gt;App.js&lt;/em&gt;, edit your codes to look like the  one below or take out the codes and replace with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "./App.css";
function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;My App&amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;em&gt;&lt;strong&gt;Index.js&lt;/strong&gt;&lt;/em&gt;, edit your codes to look like the  one below or take out the codes and replace with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  &amp;lt;React.StrictMode&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/React.StrictMode&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bring up your VS Code terminal (Ctrl + J for windows), run &lt;code&gt;npm start&lt;/code&gt;. This will start your React App on localhost port 3000 (&lt;em&gt;&lt;strong&gt;localhost:3000&lt;/strong&gt;&lt;/em&gt;). You should have an output like the picture below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg43eiryxqkwhvclfbck8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg43eiryxqkwhvclfbck8.png" alt="Image description" width="747" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you get the same output as the image above, that means you have successfully set up your react app. WELL DONE 👍👍👍&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing and Setting Up React Router
&lt;/h2&gt;

&lt;p&gt;React Router is a standard library for routing in React. It enables the navigation among views of various components in a React Application, allows changing the browser URL, and keeps the UI in sync with the URL. Official documentation &lt;a href="https://reactrouter.com/en/main" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To install React Router run &lt;code&gt;npm i react-router-dom&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In Your &lt;em&gt;&lt;strong&gt;Index.js&lt;/strong&gt;&lt;/em&gt;, import &lt;em&gt;BrowserRouter&lt;/em&gt; from react router dom and, wrap your App component With the &lt;em&gt;BrowserRouter&lt;/em&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  &amp;lt;React.StrictMode&amp;gt;
    &amp;lt;BrowserRouter&amp;gt;
      &amp;lt;App /&amp;gt;
    &amp;lt;/BrowserRouter&amp;gt;
  &amp;lt;/React.StrictMode&amp;gt;
);

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

&lt;/div&gt;



&lt;p&gt;Next up, go into the &lt;em&gt;&lt;strong&gt;App.js&lt;/strong&gt;&lt;/em&gt; file, and define your routes, you can just page the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Route, Routes } from "react-router";
import Home from "./components/Home";
import NotFound from "./components/NotFound";
import NavBar from "./components/NavBar";
import Repos from "./components/Repos";
import RepoDetails from "./components/RepoDetails";
import About from "./components/About";
import Footer from "./components/Footer";

function App() {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;NavBar /&amp;gt;
      &amp;lt;Routes&amp;gt;
        &amp;lt;Route path="/" element={&amp;lt;Home /&amp;gt;} /&amp;gt;
        &amp;lt;Route path="/repos" element={&amp;lt;Repos /&amp;gt;} /&amp;gt;
        &amp;lt;Route path="/repos/:id" element={&amp;lt;RepoDetails /&amp;gt;} /&amp;gt;
        &amp;lt;Route path="/about" element={&amp;lt;About /&amp;gt;} /&amp;gt;
        &amp;lt;Route path="*" element={&amp;lt;NotFound /&amp;gt;} /&amp;gt;
      &amp;lt;/Routes&amp;gt;
      &amp;lt;Footer /&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explaining the codes&lt;/strong&gt;&lt;br&gt;
In the above line of codes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I am importing the Route and Routes from react-router&lt;/li&gt;
&lt;li&gt;I am also importing the &lt;strong&gt;Home&lt;/strong&gt;, &lt;strong&gt;NotFound&lt;/strong&gt;, &lt;strong&gt;NavBar&lt;/strong&gt;, &lt;strong&gt;Repos&lt;/strong&gt;, &lt;strong&gt;RepoDetails&lt;/strong&gt;, &lt;strong&gt;About&lt;/strong&gt; and &lt;strong&gt;Footer&lt;/strong&gt; components from a &lt;code&gt;components&lt;/code&gt; folder in &lt;code&gt;src&lt;/code&gt;. (&lt;em&gt;the components name spells out their function&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;Home component is the homepage&lt;/li&gt;
&lt;li&gt;NotFound component is the 404 page&lt;/li&gt;
&lt;li&gt;NavBar components is the Navbar of our App&lt;/li&gt;
&lt;li&gt;Repos components is the page where the repository from our github API will be displayed.&lt;/li&gt;
&lt;li&gt;RepoDetails components is the page to show details of individual repository &lt;/li&gt;
&lt;li&gt;About components is the page where the user's GitHub details will be displayed&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Adding Bootstrap
&lt;/h2&gt;

&lt;p&gt;Bootstrap is a CSS framework, it can either be installed on the CLI or used with CDN (Cloud Delivery Network). For this project, CDN will be used. &lt;br&gt;
Go in to your Public folder, paste the following into your head of the index.html file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="stylesheet" href=https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css /&amp;gt;

&amp;lt;link href=https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css rel="stylesheet" integrity="sha384EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>design</category>
      <category>productivity</category>
      <category>uxdesign</category>
    </item>
  </channel>
</rss>
