Install router npm package.
npm install react-router-dom
import React, { Component } from 'react';
import './App.css';
import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom";
const Home = () => {
return <h3>Home page</h3>
}
const About = () => {
return <h3>About page</h3>
}
const QA = () => {
return <h3>QA</h3>
}
class App extends Component {
render() {
return (
<Router>
<Switch>
<Route path="/" exact component={Home}>Home</Route>
<Route path="/about" exact component={About}>About</Route>
<Route path="/qa" exact component={About}>QA</Route>
</Switch>
</Router>
);
}
}
export default App;
0 comments:
Post a Comment