-1

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:

https://aidablaya.github.io/portfolio-AidaBlaya/

AidaBB
  • 1
  • 1
  • 1
    What link(s) are you referring to? Can you [edit] to include your package.json file, and a link to your app where it's deployed? In the meantime, does this help answer your question? https://stackoverflow.com/a/71985764/8690857 – Drew Reese Aug 23 '23 at 15:51
  • I think your app is correctly deployed and loading/mounting, but the `app` container is empty, i.e. `
    `, which means either you haven't deployed what you think you have or no routes matched and nothing is returned. Try `"homepage": "https://aidablaya.github.io/portfolio-AidaBlaya"` in the package.json file, and when loading the app use `"https://aidablaya.github.io/portfolio-AidaBlaya/#/"`.
    – Drew Reese Aug 24 '23 at 15:30

0 Answers0