Mohamed Amine Fh
Posted on September 18, 2021
If you have tried to deploy a React App with react-router-dom to github pages, probably you'll hate yourself because it won't work as you expected 😔.
So what the heck is going on ? why is this happening?
So if you don't know gh-pages deploy your React App
to this url http://{username}.github.io/{repo-name}
and in your App the "/" route means this url http://{username}.github.io/
.
So one solution for this
is to replace the BrowserRouter with HashRouter
so instead of this
do this
Now deploy again your changes with
npm run deploy
Thats it
💖 💪 🙅 🚩
Mohamed Amine Fh
Posted on September 18, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubactions Technical Interview - Boilerplate 2 - Node + Serverless + AWS + Github Actions
November 21, 2024
webdev Mastering Compound Components: Building Flexible and Reusable React Components
November 9, 2024