Hello :),
Deployment GitHub repo displays blank page caused by BrowserRouter.
I confirm that, because I use Bitbucket to deploy the same code, and successfully it displays content of the project. Additionally, I read, that BrowserRouter could provide errors on GitHub pages.
I want to display as “home page” the "Dashboard"
component. Any ideas? How can I fix it?
I tried to fix it by adding basename={'/dashboard'}
to the Router
in function App
- not working.
main.tsx
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import App from './app/app';
ReactDOM.render(
<StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</StrictMode>,
document.getElementById('root')
);
App.tsx
import React from "react";
import "./App.css";
import axios from "axios";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import { routes, RouteType } from "./routes";
function App() {
return (
<Router>
<Switch>
{routes().map((route: RouteType, i: number) => (
<Route key={i} {...route} />
))}
</Switch>
</Router>
);
}
export default App;
routes.tsx
import { Dashboard} from "./admin/dashboard";
import React from "react";
import { Admin } from 'ui/routes/admin';
import { Application } from '/ui/routes/application';
export type RouteType = { path: string; component: React.FC };
export type RoutesType = RouteType[];
export const routes = (): RoutesType => {
return [
{ path: "/dashboard", component: Dashboard},
{ path: "/admin", component: Admin },
{ path: "/application", component: Application },
];
};