“Rota React” Respostas de código

Reaja o roteador JS

npm install react-router-dom
Roseat Flamingo

Rota React

npm install react-router-dom
Upset Unicorn

ROUTER DE REACTER

// APP.js Setup.........
import * as React from "react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import "./App.css";
import Home from "./Component/Home/Home";

function App() {
  return (
    <div className="App">
      <BrowserRouter>
       <Routes>
          <Route path="/" element={<Home />} />
       </Routes>
      </BrowserRouter>
    </div>
  );
}

export default App;


// index.js setup
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";
import reportWebVitals from "./reportWebVitals";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

reportWebVitals();
Shamimzz

ROUTER DE REACTER

react router

import { BrowserRouter as Router, Routes, Route } from "react-router-dom";

  return (
    <>
      <Router>
        <>
          <Routes>
            <>
              <Route
                exact
                path="/"
                element={
                  <>
                    <Dashboard allFaq={allFaq} />
                  </>
                }
              />
              <Route
                exact
                path="/login"
                element={
                  <>
                    <Login />
                  </>
                }
              />
            </>
          </Routes>
        </>
      </Router>
    </>
  );
Abhishek

roteador em reação

import {
    BrowserRouter as Router,
    Routes,
    Route,
    Link
} from 'react-router-dom';
Govind Mishra

Rota reagida

let routes = (
 <BrowserRouter>
      <Navbar />
      <div className="container mt-2" style={{ marginTop: 40 }}>
        <Switch>
          <Route exact path="/">
            <Home />
          </Route>
          <Route path="/about">
            <About />
          </Route>
        </Switch>
      </div>
    </BrowserRouter>
);
Irfan

Respostas semelhantes a “Rota React”

Perguntas semelhantes a “Rota React”

Mais respostas relacionadas para “Rota React” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código