react js router
npm install react-router-dom
link to react
import React, { Component } from 'react';
import { render } from 'react-dom';
import { BrowserRouter, Route, Switch, Link } from 'react-router-dom';
import { Home } from 'wherever-you-put-it/home.component.jsx';
import { Something } from 'wherever-you-put-it/something.component.jsx';
import { SomethingElse } from 'wherever-you-put-it/something-else.component.jsx';
class App extends Component {
render() {
return (
<BrowserRouter>
<Switch>
<Route path="/">
<Home />
</Route>
<Route path="/something">
<Something />
</Route>
<Route path="/somethingelse">
<SomethingElse />
</Route>
</Switch>
<SomeComponentOrElement>
<Link to="/">Home</Link>
<Link to="/something">Something</Link>
<Link to="/somethingelse">Something Else</Link>
</SomeComponentOrElement>
</BrowserRouter>
)
}
}
render(<App />, document.getElementById('app'));
route react
import React from "react";
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
export default function App() {
return (
<Router>
<div>
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
<li>
<Link to="/users">Users</Link>
</li>
</ul>
</nav>
{/* A <Switch> looks through its children <Route>s and
renders the first one that matches the current URL. */}
<Switch>
<Route path="/about">
<About />
</Route>
<Route path="/users">
<Users />
</Route>
<Route path="/">
<Home />
</Route>
</Switch>
</div>
</Router>
);
}
function Home() {
return <h2>Home</h2>;
}
function About() {
return <h2>About</h2>;
}
function Users() {
return <h2>Users</h2>;
}
react routes
npm install react-router-dom
routes react
npm install --save react-router-dom
routing in react
npm install react-router-dom
to install the react router to create a specific urls in react
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us