<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Galo Hernandez on Medium]]></title>
        <description><![CDATA[Stories by Galo Hernandez on Medium]]></description>
        <link>https://medium.com/@galohernandez?source=rss-1eee44f3098a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0sOYS27QKeYccJ2mUlWk5A.png</url>
            <title>Stories by Galo Hernandez on Medium</title>
            <link>https://medium.com/@galohernandez?source=rss-1eee44f3098a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:15:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@galohernandez/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to push your Python project to GitLab — the latest way!]]></title>
            <link>https://medium.com/@galohernandez/pushing-your-first-project-to-gitlab-can-be-very-tricky-9f18f9a7a504?source=rss-1eee44f3098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f18f9a7a504</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Galo Hernandez]]></dc:creator>
            <pubDate>Wed, 26 Apr 2023 00:53:45 GMT</pubDate>
            <atom:updated>2023-06-02T16:22:23.037Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m95J8s3ua43GjqXo" /><figcaption>Photo by <a href="https://unsplash.com/@mparzuchowski?utm_source=medium&amp;utm_medium=referral">Michał Parzuchowski</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this mini-tutorial, I will share the steps, fixes, and pain I had to deal with pushing my Python project to GitLab.</p><p>First of all the problems that I had should not be taken like this will happen to you in the same way for your project. I guess that the majority of projects uploaded to GitLab had no problems at all.</p><p>Most of the problems that I faced are more related to holes in the documentation on the GitLab website or personal “should know that” problems.</p><h3>About the project</h3><p>My project is a Python OCR application that uses AI to improve assistance in searching for information. I will not talk about this project but only about the process of using GitLab to store my project.</p><h3>What is GitLab</h3><p>GitLab is an open-source code repository and collaborative software development platform for large DevOps and DevSecOps projects. GitLab is free for individuals. GitLab offers a location for online code storage and capabilities for issue tracking and CI/CD.</p><h3>The steps you need for using GitLab</h3><p>I will show the steps you need to make this work. While I was searching for solutions to my problems I found a lot of Forums with devs facing a lot of problems using GitLab so my solution will or not will help you with your specific problem. I hope this will help you!</p><p>First things first. I am using:</p><ul><li>Macbook M2 with Visual Studio Code</li><li>Chrome browser</li></ul><p>Ok let’s begin:</p><ol><li>First, you need to create an account in GitLab. The process is not hard so I will skip these steps</li><li>For your projects, you need to create a Group and inside that Group you can create your project</li><li>After you create your project you will get an address with a .git extension</li><li>On your computer, you need to create the SSH key pair to communicate securely with GitLab. The steps for this are:</li></ol><pre>ssh-keygen -t ed25519 -C &quot;youremail@email.com&quot;</pre><p>I used the ed25519 algorithm because is recommended by GitLab but you can use other types of algorithms if you want</p><p>After running this in your project console a folder is created in your user’s root path (Users/your_name/.ssh)</p><p>You can add even more security using “paraphrased texts” if you want. There are plenty more options for the creation of ssh keys. Maybe in another tutorial, I will go deep into this.</p><p>After you run the code for the creation of the SSH Keys you will get some information from the console about where your Keys were saved, your fingerprint, and even a random image of your Keys</p><p>5. The next step is to paste your recently created SSH Keys pair into your GitLab profile. Here there are the steps suggested by the GitLab website (<a href="https://docs.gitlab.com/ee/user/ssh.html">https://docs.gitlab.com/ee/user/ssh.html</a>):</p><ol><li>First, need to copy your ssh key pair, you have to use this console code:</li></ol><pre>tr -d &#39;\\n&#39; &lt; ~/.ssh/id_ed25519.pub | pbcopy</pre><p>b. In your profile, choose edit.</p><p>c. On the left sidebar, select SSH Keys. d. In the Key box, paste the contents of your public key.</p><p>e. There you have other details options like Tittle, Usage Type, and Expiration Type. You can fill these options with your info</p><p>f. Finally add the key</p><p>6. The next step is to verify the connection is established for that you have this instruction:</p><p>Open a terminal and run this command, replacing <a href="http://gitlab.example.com/">gitlab.example.com</a> with your GitLab instance URL:</p><pre>ssh -T git@gitlab.example.com</pre><p>Then you have the first WTH question. What is your <strong><em>GitLab instance URL</em></strong>???</p><p>You instantly will think. Ok, is my project URL? Maybe my user followed by @gitlab or something…</p><p>There is no really a good answer for this on the GitLab website. After searching forums I found that you should replace <a href="http://gitlab.example.com/">gitlab.example.com</a> with: <a href="http://gitlab.com/"><strong>gitlab.com</strong></a></p><pre>ssh -T git@gitlab.com</pre><p>After this, you will have another like “scary message” from your computer. You have to just accept the warning and finally, the GitLab website will send you a message with your name on it saying “Welcome your_user_name”</p><pre>The authenticity of host &#39;gitlab.com (2686:4500:90:0:f22e:fbbc:5bed:a9b9)&#39; can&#39;t be established.<br>ED25519 key fingerprint is SHA256:eUIFGb1YGsMAS7bkcx6JOJdOGHPem5gQn4taiCfCLB8.<br>This key is not known by any other names<br><br>Are you sure you want to continue connecting (yes/no/[fingerprint])? yes<br><br>Warning: Permanently added &#39;gitlab.com&#39; (ED25519) to the list of known hosts.<br><br>Welcome to GitLab, @ghernandez!</pre><p>7. So, you say. Ok, finally I can upload my project to GitLab. let’s use the git commands:</p><ul><li>Init the git:</li></ul><pre>git init</pre><ul><li>Add the GitLab repository as a remote:</li></ul><p>a. Copy the repository URL from your GitLab project page (it should look like <a href="https://gitlab.com/username/project-name.git">https://gitlab.com/username/project-name.git</a>). In the terminal, run the following command to add the remote repository</p><pre>git remote add origin https://gitlab.com/username/project-name.git</pre><p>b. Add the project files to the git:</p><pre>git add .</pre><p>c. Commit:</p><pre>git commit -m &quot;Your commit message&quot;</pre><p>d. Configure your credentials:</p><ul><li>Configure your email: <strong>git config --global user.email &quot;your.email@example.com&quot;</strong></li><li>Configure your name: <strong>git config --global user.name &quot;Your Name&quot;</strong></li></ul><p>e. Push your changes to GitLab</p><pre>git push -u origin master</pre><p>The previous steps SHOULD WORK but not in my case. I will show what errors happened to me but according to several forums, you will have the same or different errors. I just hope the next steps will help you fix your own errors:</p><ul><li>The first error you will find is that you have to use “main” instead of “master” in your push so the correct command for pushing is:</li></ul><pre>git push -v origin main</pre><p>I changed the “u” for “v” in order to get more information on the process in the console because when I tried with the “u” my console got freeze without any message (because there are other errors that I will show you..). So, I included the “v” to check what other errors I got.</p><ul><li>I got this error:</li></ul><blockquote>remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password.</blockquote><p>This error was very tricky to resolve:</p><ul><li>First I tried to use the VS Code GitLab extension “GitLab Workflow” in order to fix the authentication problem. (Optional maybe…)</li><li>The extension setup has a lot of steps to follow. I don&#39;t know if the steps I followed someway helped with the final fix for the error. Anyway you can step forward to the <strong>final fix solution</strong> or you can try these extension steps before applying it:</li></ul><p>I will comment on all the steps:</p><h4>Setup of the extension</h4><p>This extension requires you to create a GitLab personal access token, and assign it to the extension:</p><ul><li>Install the extension from the Visual Studio Marketplace and enable it. If you use an unofficial version of VS Code, install the extension from the Open VSX Registry.</li></ul><blockquote>I did the installation from the VSCode marketplace</blockquote><ul><li>Optional. To sign in to <a href="http://gitlab.com/">GitLab.com</a>, you can run the command GitLab: Authenticate to <a href="http://gitlab.com/">GitLab.com</a> to authenticate using OAuth. This feature is not available for self-managed installations.</li></ul><blockquote>I did this and immediately tried the git push. No luck...</blockquote><ul><li>If you did not sign in with OAuth, create a personal access token with the API and read_user scopes:</li></ul><blockquote>I went to <a href="http://gitlab.com/">GitLab.com</a>, then to the <a href="https://gitlab.com/-/profile/personal_access_tokens">personal access tokens page</a>, and followed the steps. Those steps I will not cover here because are very simple to use. Something you must not forget is to apply the “API” scope.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c4uOqjHeTAPK5-Lx06wFzw.png" /></figure><ul><li>Copy the token. For security reasons, this value is never displayed again, so you must copy this value now.</li><li>Open Visual Studio Code, then open the command palette by pressing Command + Shift + P.</li><li>In the command palette, search for GitLab: Add Account and press Enter. In the URL to GitLab instance, paste the full URL to your GitLab instance, including the http:// or <a href="https://./">https://.</a> Press Enter to confirm.</li></ul><blockquote>Here VSCode automatically filled the field with <a href="http://gitlab.com/">gitlab.com</a> so just ENTER to the next step.</blockquote><ul><li>Paste in your GitLab personal access token and press Enter. The token is not displayed, nor is it accessible to others.</li></ul><blockquote>You paste here your GitLab token you just created</blockquote><p>After all these steps you got a connection success message. There you say. Ok, finally!! but no...</p><p>After you try the GIT commands you will get the same authentication error:</p><blockquote>remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password.</blockquote><h3>The desperation…</h3><p>After all this long process you still have the error. I will show you some of the things I tried in order you do not have to waste your time trying to do the same:</p><ul><li>Some forums suggested that my password helper was broken and that&#39;s why the authentication failed again and again. So, I tried to fix this with this code but the error remains:</li></ul><pre>git config --global credential.helper osxkeychain</pre><ul><li>I tried to force with the git config command to apply my password but again no luck:</li></ul><pre>git config --global user.password your_password</pre><ul><li>I tried to unset my password in order to make the git asks me for my password again, but no luck:</li></ul><pre>git config --system --unset credential.helper</pre><ul><li>Another forum suggested including my user in the git origin but no luck:</li></ul><pre>git remote add origin https://your_user_name@gitlab.com/groupofprojects/your_project.git/</pre><p>The console said that the remote origin already existed so I tried to remove the remote origin from git:</p><pre>git remote remove origin</pre><p>and tried again but no luck…</p><h3>The Fix</h3><p>I almost quit but I tried one more “forced use” of the password but this time I included my GitLab password in the origin with my user. This was suggested by another forum too. First I removed the remote origin then I used the git command for remote add origin again:</p><pre>git remote add origin https://your_user_name:your_password@gitlab.com/projects_group/your_project_name.git/</pre><p>I repeated the complete git process and when I finally did the “git push” with the “v” parameter finally I got a new error but I was authenticated!!</p><blockquote>error: failed to push some refs to ‘https://gitlab.com/your_project_group/your_project_name.git/&#39; hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., ‘git pull …’) before pushing again. hint: See the ‘Note about fast-forwards’ in ‘git push — help’ for details.</blockquote><p>I think there was some internal confusion after all the tries but this error is because you have to reconcile the remote and local structures of your project so I did a pull and a rebase to fix this:</p><pre>git pull origin main<br><br>git config pull.rebase true</pre><p>then I repeated the “git pull origin main” instruction</p><p>Finally, I did the pushing again:</p><pre>git push -v origin main</pre><p>and Voila!!!</p><p>I got this message in the console that confirmed that my code was uploaded successfully to GitLab:</p><blockquote>Pushing to <a href="https://gitlab.com/pythonproject/busdoclab.git/">https://gitlab.com/your_project_group/your_project_name.git/</a> Enumerating objects: 74, done. Counting objects: 100% (74/74), done. Delta compression using up to 8 threads Compressing objects: 100% (70/70), done. POST git-receive-pack (chunked) Writing objects: 100% (73/73), 3.11 MiB | 1.08 MiB/s, done. Total 73 (delta 25), reused 0 (delta 0), pack-reused 0 To <a href="https://gitlab.com/pythonprojects/busdocdoclab.git/">https://gitlab.com/your_project_group/your_project_name.git/</a> 9cc4ca4..66ccd4af main -&gt; main updating local tracking ref ‘refs/remotes/origin/main’</blockquote><p>I checked in GitLab and my structure was uploaded !!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wM5XEh8GYzIfe3IW5apcIA.png" /></figure><h3>Final Thoughts: Poor documentation??</h3><ul><li>I think there is poor documentation in GitLab for your first projects. Maybe its because the website has a lot of configurations, options, advanced topics, and all the great benefits you got with this git solution</li><li>In my search for answers, there were a lot of different errors posted from users and a lot of different answers for the same problem so again I think there is poor documentation on the GitLab website</li><li>The VSCode extension is not completely updated with the instructions provided. Some things are different when you run the suggested steps and someway you have to figure out and compare in order to advance in the process</li></ul><p>Please let me know your thoughts on this. I will love to answer any question or learn new ways for doing the same.</p><p>See you in the matrix!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f18f9a7a504" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vite-React + React-Router-Dom: The latest way!!]]></title>
            <link>https://medium.com/@galohernandez/vite-react-react-router-dom-the-latest-way-312ee887197e?source=rss-1eee44f3098a------2</link>
            <guid isPermaLink="false">https://medium.com/p/312ee887197e</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-router-dom]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ant-design]]></category>
            <dc:creator><![CDATA[Galo Hernandez]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 02:55:37 GMT</pubDate>
            <atom:updated>2023-02-19T02:55:37.848Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nRUjTaiN1SCbMtsX" /><figcaption>Photo by <a href="https://unsplash.com/@sigmund?utm_source=medium&amp;utm_medium=referral">Sigmund</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The short story is that I was following just another e-commerce tutorial and found out that most of them are OUTDATED so I challenged myself to find how to resolve the puzzle with the latest versions of everything.</p><p>I must mention that the tutorial I am using is from 2021 so it seems that is very, very old now by today&#39;s standards. Those kinds of things are the obstacles most web developers face day after day.</p><p>This will be the first of several mini-tutorials. Hopefully, I will share with you my advances in the easiest way to follow and someday finish the complete e-commerce web application.</p><p>In this mini-tutorial, we will end with a react-router-dom implementation with 3 pages using Vite+React and for styling Antd and Bootstrap.</p><p>Hopefully, you will follow these steps to get the same result:</p><ol><li><strong>React installation</strong></li></ol><p>First things first! What is the proper way to install React? I will not go deep on this but it seems most “YouTube web gurus” say that “create-react-app” is finished and most of them recommend using Vite to do this so I accepted the challenge.</p><p>I had several problems with “create-react-app” too. For example, the “npm start” does not work properly because I use the latest Node and NPM versions so I had to use some hacks to make this work. I can share that hack with you in the messages section if you want.</p><p>By the way, my oldie e-commerce tutorial uses “create-react-app”.</p><p>I will use VS Code throughout all these series of mini tutorials.</p><p>Just because we are creating an e-commerce app I named the front-end part “client”. For installing React with Vite open your terminal and use this command:</p><pre>npm create vite@latest client -- --template react</pre><p>The process is very fast compared to “create-react-app”. After finishing it will ask you to cd to your client folder and then run the command:</p><pre>npm install</pre><p>It is possible that you will have to fix some warnings. You can do this if you want with “npm audit-fix”.</p><p>Then you can run the project using this line of code:</p><pre>npm run dev</pre><p>The console will tell you that your app is running in localhost: 5173 (this is already different from the usual 3000 port!).</p><p>Then you will see the Vite+React basic front page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UvReSxFr_E11hhECGQOUkA.png" /><figcaption>Default front page: Vite+React</figcaption></figure><p>When you look at the structure tree you can notice some differences from the “usual” React installation:</p><ul><li>There is no index.js but main.jsx</li><li>no vitals js</li><li>a vite-config.js</li><li>a vite svg (for the basic front)</li><li>other stuff in node_modules that are beyond the purpose of this mini-tutorial</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*9Lmz-qOqaEnW4nRYfKn9ng.png" /><figcaption>Vite — React base structure</figcaption></figure><p><strong>2. The cleaning</strong></p><p>The cleaning process is for just getting rid of any code that we will not actually use.</p><p>I remove everything from App.jsx. It will end like this:</p><pre>function App() {<br><br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      Vite APP<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default App</pre><p>You can delete:</p><ul><li>app.css</li><li>the svg</li><li>just lets index.css without any code</li></ul><p><strong>3. Back to the tutorial guide!</strong></p><p>As I mentioned before I am following an oldie 2021 e-commerce tutorial. The author wants me to use 2 different styling solutions:</p><ul><li><strong>Antd</strong>: This is an implementation for React of the Ant Design principles. Well, that is what they say on their website. I don&#39;t know why some modern websites don&#39;t have a little history or “about this” link. Anyway, to install this you need to run this line of code:</li></ul><pre>npm install antd     </pre><ul><li><strong>Bootstrap — React-bootstrap</strong>: I guess we all know what is Bootstrap but I will resume that as a collection of design components and other stuff. In 2023 is not recommended by most “web gurus” too. Tailwind is the new thing but we will follow our original instructions. To install run this line of code:</li></ul><pre>npm install react-bootstrap bootstrap   </pre><p>and in the main.jsx import it:</p><pre>import &#39;bootstrap/dist/css/bootstrap.min.css&#39;;</pre><p>And there you are ready to go for using both CSS libraries</p><p><strong>4. Creating the pages</strong></p><p>We need to create a “Pages” folder and an “Auth” folder in the root</p><p>Then make 3 pages: Home, Register, and Login. Each JSX file should have the basic structure like this Home.js:</p><pre>import React from &#39;react&#39;<br><br>const Home = () =&gt; {<br>  return (<br>    &lt;div&gt;Home&lt;/div&gt;<br>  )<br>}<br><br>export default Home</pre><p>We have to make a Header for our application. First, we create a Folder called components and inside a new folder called nav. We create then a new file called Header.jsx with a basic structure.</p><p>In this Header.jsx file we are going to use a MENU component that is part of the Antd components. The base model for this Nav looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q4TGwolICUw3qK_DsxUF7A.png" /></figure><p>The code for this MENU is:</p><pre>import { AppstoreOutlined, MailOutlined, SettingOutlined } from &#39;@ant-design/icons&#39;;<br>import { Menu } from &#39;antd&#39;;<br>import { useState } from &#39;react&#39;;<br>const items = [<br>  {<br>    label: &#39;Navigation One&#39;,<br>    key: &#39;mail&#39;,<br>    icon: &lt;MailOutlined /&gt;,<br>  },<br>  {<br>    label: &#39;Navigation Two&#39;,<br>    key: &#39;app&#39;,<br>    icon: &lt;AppstoreOutlined /&gt;,<br>    disabled: true,<br>  },<br>  {<br>    label: &#39;Navigation Three - Submenu&#39;,<br>    key: &#39;SubMenu&#39;,<br>    icon: &lt;SettingOutlined /&gt;,<br>    children: [<br>      {<br>        type: &#39;group&#39;,<br>        label: &#39;Item 1&#39;,<br>        children: [<br>          {<br>            label: &#39;Option 1&#39;,<br>            key: &#39;setting:1&#39;,<br>          },<br>          {<br>            label: &#39;Option 2&#39;,<br>            key: &#39;setting:2&#39;,<br>          },<br>        ],<br>      },<br>      {<br>        type: &#39;group&#39;,<br>        label: &#39;Item 2&#39;,<br>        children: [<br>          {<br>            label: &#39;Option 3&#39;,<br>            key: &#39;setting:3&#39;,<br>          },<br>          {<br>            label: &#39;Option 4&#39;,<br>            key: &#39;setting:4&#39;,<br>          },<br>        ],<br>      },<br>    ],<br>  },<br>  {<br>    label: (<br>      &lt;a href=&quot;https://ant.design&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;<br>        Navigation Four - Link<br>      &lt;/a&gt;<br>    ),<br>    key: &#39;alipay&#39;,<br>  },<br>];<br>const App = () =&gt; {<br>  const [current, setCurrent] = useState(&#39;mail&#39;);<br>  const onClick = (e) =&gt; {<br>    console.log(&#39;click &#39;, e);<br>    setCurrent(e.key);<br>  };<br>  return &lt;Menu onClick={onClick} selectedKeys={[current]} mode=&quot;horizontal&quot; items={items} /&gt;;<br>};<br>export default App;</pre><p>This code has to be adapted to our pages and paths</p><p><strong>5. About installing and using the new react-router-dom v.6</strong></p><p>This is kinda the “tricky” part of this mini-tutorial because the documentation for our purpose is not very clear for the latest version of react-router-dom. (Version 6).</p><p>To install the latest version run this line of code in your terminal:</p><pre>npm install react-router-dom localforage match-sorter sort-by</pre><p>In the 5 version and past versions, we were used to encapsulating our pages inside our Layout:</p><pre>import React from &quot;react&quot;;<br>import { BrowserRouter as Router, Route } from &quot;react-router-dom&quot;;<br>import Layout from &quot;./Layout&quot;;<br>import HomePage from &quot;./HomePage&quot;;<br>import AboutPage from &quot;./AboutPage&quot;;<br><br>const App = () =&gt; {<br>  return (<br>    &lt;Router&gt;<br>      &lt;Layout&gt;<br>        &lt;Route exact path=&quot;/&quot; render={() =&gt; &lt;HomePage /&gt;} /&gt;<br>        &lt;Route exact path=&quot;/about&quot; render={() =&gt; &lt;AboutPage /&gt;} /&gt;<br>      &lt;/Layout&gt;<br>    &lt;/Router&gt;<br>  );<br>};<br><br>export default App;</pre><p>now with the new version, the Layout is included in an “element” property of our root path that will encapsulate all pages but uses some “special components” that are kinda hard to find in the new documentation.</p><p>I tried to find a solution in the react-router-dom documentation but they only include a few examples in different Layout situations.</p><p>After failing to find answers there I tried to find some solutions in Google, then StackOverflow and others but no luck.</p><p>Finally, I went to the new dev toy CHATGPT but the solutions it gave me were outdated too, and after a few “apologies” from HIM/HER, I tried to return to the documentation and look for a solution.</p><pre>import React from &quot;react&quot;;<br>import { BrowserRouter, Routes, Route } from &quot;react-router-dom&quot;;<br>import Layout from &quot;./Layout&quot;;<br>import HomePage from &quot;./HomePage&quot;;<br>import AboutPage from &quot;./AboutPage&quot;;<br><br>const App = () =&gt; {<br>  return (<br>    &lt;BrowserRouter&gt;<br>      &lt;Routes&gt;<br>        &lt;Route path=&quot;/&quot; element={&lt;Layout /&gt;}&gt;<br>          &lt;Route path=&quot;/&quot; element={&lt;HomePage /&gt;} /&gt;<br>          &lt;Route path=&quot;/about&quot; element={&lt;AboutPage /&gt;} /&gt;<br>        &lt;/Route&gt;<br>      &lt;/Routes&gt;<br>    &lt;/BrowserRouter&gt;<br>  );<br>};<br><br>export default App;</pre><p>This last code was generated by ChatGPT but is actually wrong because BrowserRouter is not used anymore in the latest version of react-router-dom</p><p>So, I returned back to react-router-dom documentation and after watching some YouTube things here and other things on Google I managed to figure out how to implement this the proper way.</p><p>Getting back to our project we have to implement this for our case:</p><p>We need to use some functionalities from react-router-dom version 6 :</p><ul><li>createBrowserRouter</li><li>createRoutesFromElements</li><li>RouteProvider</li><li>Route</li></ul><p>Now use them in your App.jsx file:</p><pre>import React from &#39;react&#39;;<br>import { Route, createBrowserRouter, createRoutesFromElements, RouterProvider } from &#39;react-router-dom&#39;;<br>import Home from &#39;./pages/Home&#39;;<br>import Login from &#39;./pages/auth/Login&#39;;<br>import Register from &#39;./pages/auth/Register&#39;;<br>import Header from &#39;./components/nav/Header&#39;;<br><br><br><br>const router = createBrowserRouter(<br>  createRoutesFromElements(<br>    &lt;Route path=&quot;/&quot; element={&lt;Header /&gt;}&gt;<br>      &lt;Route index element={&lt;Home /&gt;} /&gt;<br>      &lt;Route path=&quot;login&quot; element={&lt;Login /&gt;} /&gt;<br>      &lt;Route path=&quot;register&quot; element={&lt;Register /&gt;} /&gt;<br>    &lt;/Route&gt;<br>  )<br>)<br><br>function App({routes}) {<br><br>  return (<br>    &lt;&gt;<br>      &lt;RouterProvider router={router}/&gt;<br>    &lt;/&gt;<br>  );<br>}<br><br>export default App;<br><br></pre><p>The Header element is used as a property of the root path “/” but in order to make it work in all paths including the “Home component that is /” you have to define an “index element” for the Home component.</p><p>We now have to adapt the Header component to fit our project needs and use “react-router-dom”.</p><p>We will use these elements from the react-router-dom version 6:</p><ul><li>Outlet</li><li>Link</li></ul><p>After making some changes like deleting some code parts related to submenus and changing icons we will get a code something like this:</p><pre>import { HomeTwoTone, EditTwoTone, CheckCircleTwoTone } from &#39;@ant-design/icons&#39;;<br>import { Menu } from &#39;antd&#39;;<br>import { useState } from &#39;react&#39;;<br>import { Outlet, Link } from &#39;react-router-dom&#39;;<br><br><br>const Header = () =&gt; {<br>  const [current, setCurrent] = useState(&#39;h&#39;);<br>  const onClick = (e) =&gt; {<br>    console.log(&#39;click &#39;, e);<br>    setCurrent(e.key);<br>  };<br>  return (<br>    &lt;&gt;<br>     &lt;Menu onClick={onClick} selectedKeys={[current]} mode=&quot;horizontal&quot;&gt;<br>      &lt;Menu.Item key=&quot;h&quot; icon= {&lt;HomeTwoTone /&gt;}&gt;<br>       &lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;<br>      &lt;/Menu.Item&gt;<br>      &lt;Menu.Item key=&quot;r&quot; icon= {&lt;EditTwoTone /&gt;}&gt;<br>        &lt;Link to=&quot;/register&quot;&gt;Register&lt;/Link&gt;<br>      &lt;/Menu.Item&gt;<br>      &lt;Menu.Item key=&quot;l&quot; icon= {&lt;CheckCircleTwoTone /&gt;}&gt;<br>        &lt;Link to=&quot;/login&quot;&gt;Login&lt;/Link&gt;<br>      &lt;/Menu.Item&gt;<br>     &lt;/Menu&gt;<br>     &lt;Outlet/&gt;<br>    &lt;/&gt;<br>   <br>  )<br>};<br>export default Header;</pre><p>Some of the changes we made:</p><ul><li>We use Outlet to show the contents of the different links.</li><li>We use Link to replace href and similar</li><li>We add some icons related to our links nature. For this and more icons, you can visit the Ant Design icons library</li></ul><p>Finally, you will get your new Nav built with the latest react-router-dom, latest react, using vite and Antd Design.</p><p>But wait me a second… Why I installed Bootstrap and never use it? Well, in my oldie tutorial, the author wants to move to the right just “Register” and “Login” Links.</p><p>For this purpose, you can use a class called “ml-auto” but unfortunately, this class is incompatible now with Ant Design components. This doesn&#39;t mean that Bootstrap is incompatible with And Design at all. You can use Bootstrap in any component of the application.</p><p>Instead, you can use an inline style to make the change. Our header will have this final code in the Menu component:</p><pre> &lt;Menu onClick={onClick} selectedKeys={[current]} mode=&quot;horizontal&quot;&gt;<br>      &lt;Menu.Item key=&quot;h&quot; icon= {&lt;HomeTwoTone /&gt;}&gt;<br>       &lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;<br>      &lt;/Menu.Item&gt;<br>      &lt;Menu.Item key=&quot;r&quot; icon= {&lt;EditTwoTone /&gt;} style={{ marginLeft: &#39;auto&#39; }}&gt;<br>        &lt;Link to=&quot;/register&quot;&gt;Register&lt;/Link&gt;<br>      &lt;/Menu.Item&gt;<br>      &lt;Menu.Item key=&quot;l&quot; icon= {&lt;CheckCircleTwoTone /&gt;} &gt;<br>        &lt;Link to=&quot;/login&quot;&gt;Login&lt;/Link&gt;<br>      &lt;/Menu.Item&gt;<br>     &lt;/Menu&gt;</pre><p>Finally, the app will look like this now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*klxCETLbOCMnOav51z5DpA.png" /></figure><p>This ends the first part of this series of mini-tutorials. I will keep uploading for advances in creating a complete e-commerce application using the latest technologies with a very old tutorial.</p><p>See ya soon!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=312ee887197e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>