Last active
October 9, 2020 11:54
-
-
Save adityapatnaik/487ebac85fc4fcdcd7e9cdf46065b2b4 to your computer and use it in GitHub Desktop.
How to implement Routing in Electron with React: Why not BrowserRouter in Electron?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {BrowserRouter,Link,Route,Switch} from "react-router-dom"; | |
const Stand = ()=>{ | |
return( | |
<Stand/> | |
) | |
} | |
const Sit = ()=>{ | |
return( | |
<Sit/> | |
) | |
} | |
const Home = ()=>{ | |
return( | |
<Home/> | |
) | |
} | |
const App = (props)=> { | |
return ( | |
<BrowserRouter> | |
<div className="App"> | |
<div className="menu"> | |
<Link to="/"><h2>Home</h2></Link> | |
<Link to="/one"><h2>Stand</h2></Link> | |
<Link to="/two"><h2>Sit</h2></Link> | |
</div> | |
<Switch> | |
<Route exact path="/" component={Home}/> | |
<Route exact path="/one" component={Stand}/> | |
<Route exact path="/two" component={Sit}/> | |
</Switch> | |
</div> | |
</BrowserRouter> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment