Skip to content

I need someone help me with react router 6. #7905

Closed Answered by webstarlee
athenaweb629 asked this question in General
Discussion options

You must be logged in to vote

React Router 6 introduces a few changes compared to previous versions, so let's go through the basic steps to set it up and use it in your React application:

  1. Install React Router:
    npm install react-router-dom@next
  2. Import necessary components from React Router:
    import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
  3. Set up the router component in your main App.js file:

function App() {
  return (
    <Router>
      <Route exact path="/" component={Home} />
      <Route exact path="/about" component={About} />
    </Router>
  );
}
  1. Define your route components:

function Home() {
  return <h1>Home Page</h1>;
}

function About() {
  return <h1>About Page</h1>;
}
  1. Use t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by athenaweb629
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants