To upload react app on git hub with the link:

Step 1:

Make a 404.html file in the public folder

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Page not found</title>
<script type="text/javascript">
var pathSegmentsToKeep = 1;

var l = window.location;
l.replace(
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
(
l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~'): '') +
l.hash
);

</script>
</head>
<body>
</body>
</html>

Step 2:

Copy this block of code into the index.html Public folder itself

<!-- github -->
<script type="text/javascript">
(function (l) {
if (
l.search[1] === "/") {
var decoded =
l.search
.slice(1)
.split("&")
.map(function (s) {
return s.replace(/~and~/g, "&");
})
.join("?");
window.history.replaceState(
null,
null,
l.pathname.slice(0, -1) + decoded + l.hash
);
}
})(window.location);
</script>

Step 3:

Now go to the src folder → index.js (for React router dom)

ReactDOM.render(
<Router basename="/PATH_OF_GITHUB" >
  <App />
</Router>,
document.getElementById("root")
);

Step 4:

"homepage": "https://abhimrt.github.io/GITHUB_REPO_NAME/",

Step 5:

Now run this command in your terminal

npm install --save gh-pages

Step 6:

Add these commands in your package.json

"scripts": {
+   "predeploy": "npm run build",
+   "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",

Step 7:

Commit all of your data on the git hub

Step 8

Now deploy your website by running this command

npm run deploy

BONUS:

Use the image given below for no further problems

<img src={require("../images/img-1.png")} alt="" />