Search code snippets, questions, articles...

Navigate or link to another page React

//INSTALLATTION - npm install react-router-dom
import React from "react";
import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom";

export default function App() {
    return (
                <li><Link to="/">Home</Link></li>
                <li><Link to="/about">About</Link></li>
                <li><Link to="/contact">Contact</Link></li>

                <Route exact path="/" component={Home} />
                <Route exact path="/about" component={About} />
                <Route exact path="/contact" component={Contact} />

Package Installation

npm install react-router-dom

You can use the react-router-dom npm package to navigate to other pages or components in React.

Search Index Data (The code snippet can also be found with below search text)

Routing in React
Was this helpful?
Programming Feeds
Learn something new everyday on Devsheet