I have a react project, on localhost it shows me everything but when I upload it to the git hub pages and open it from the link it shows nothing, it comes out blank. I leave the index.js file, where I have used react router as in other projects that do work:
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './components/App';
import { HashRouter } from 'react-router-dom';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<HashRouter>
<App />
</HashRouter>
);
I also attach my App.js document where the routes can be seen:
import React from 'react';
import { Route, Routes} from 'react-router-dom';
import '../styles/App.scss';
import Works from '../pages/Works';
import Landing from '../pages/Landing';
import Contact from '../pages/Contact';
function App() {
return (
<div className="App">
<Routes>
<Route path="/" element={
<>
<Landing />
</>
} />
<Route path="/works" element={
<>
<Works />
</>
} />
<Route path="/contact" element={
<>
<Contact />
</>
} />
</Routes>
</div>
);
}
export default App;
and in package.json I have the path homepage:"./" and I have checked the npm in case something was not installed. If needed I can share more code from the project or the link. Thanks :)
I try to upload my react project in git hub pages
package.json:
{
"name": "react-starter-kit",
"homepage": "./",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/free-brands-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"node-sass": "^7.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.14.1",
"react-scripts": "5.0.1",
"reactjs-popup": "^2.0.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"githubpages": "rm -rf build && rm -rf docs && npm run build && mv build docs && git add docs/* && git commit -m \"Publish in GitHub Pages\" && git push"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
this is the link where I am trying to deploy it: