import { BrowserRouter, Route, Routes } from "react-router-dom"; import PacientsPage from "../components/mainPage/pacientesPage/pacietspage"; import Mainpage from "../components/mainPage/mainpage"; import BedsPage from "../components/mainPage/bedsPage/bedspage"; import DoctorsPage from "../components/mainPage/doctorsPage/doctorsPage"; import InternationPage from "../components/mainPage/internationsPage/internationpage"; import LoginPage from "../components/loginPage/loginpage"; const MyRoutes = () => { return( <BrowserRouter> <Routes> <Route path="/*" Component={Mainpage}></Route> <Route path="/login" Component={LoginPage}></Route> <Route path="/patients" Component={PacientsPage}></Route> <Route path="/beds" Component={BedsPage}></Route> <Route path="/doctors" Component={DoctorsPage}></Route> <Route path="/internations" Component={InternationPage}></Route> </Routes> </BrowserRouter> ) } export default MyRoutes;
My goal is just to navigate between pages but now nothing works I calmly went to do my navigation and I ran into a problem where react started asking for "index.js" and from the beginning I was doing it in a typescript template so since I didn't find a solution I started one new app and passed my component to the new app and rewrote the router and from then on it's like this
P粉2427419212023-09-13 13:55:56
I think this is your main/index page.
<Route path="/*" element={<Mainpage/>}></Route>
As a learner, I could be wrong, but adding /*
would make it a wildcard route. This means anything you put after /
will go to the
component.
P粉5746952152023-09-13 09:28:10
Try this:
import { BrowserRouter, Route, Routes } from "react-router-dom"; import PacientsPage from "../components/mainPage/pacientesPage/pacietspage"; import Mainpage from "../components/mainPage/mainpage"; import BedsPage from "../components/mainPage/bedsPage/bedspage"; import DoctorsPage from "../components/mainPage/doctorsPage/doctorsPage"; import InternationPage from "../components/mainPage/internationsPage/internationpage"; import LoginPage from "../components/loginPage/loginpage"; const MyRoutes = () => { return( <BrowserRouter> <Routes> <Route path="/*" element={<Mainpage/>}></Route> <Route path="/login" element={<LoginPage/>}></Route> <Route path="/patients" element={<PacientsPage/>}></Route> <Route path="/beds" element={<BedsPage/>}></Route> <Route path="/doctors" element={<DoctorsPage/>}></Route> <Route path="/internations" element={<InternationPage/>}></Route> </Routes> </BrowserRouter> ) } export default MyRoutes;