Created
October 9, 2020 11:56
-
-
Save adityapatnaik/a39b19f03c02f38f6abb2039901bc432 to your computer and use it in GitHub Desktop.
How to implement Routing in Electron with React: Hashed Router to the rescue.
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 {HashRouter,Link,Route,Switch} from "react-router-dom"; | |
const Stand = ()=>{ | |
return( | |
<Stand/> | |
) | |
} | |
const Sit = ()=>{ | |
return( | |
<Sit/> | |
) | |
} | |
const Home = ()=>{ | |
return( | |
<Home/> | |
) | |
} | |
const App = (props)=> { | |
return ( | |
<HashRouter> | |
<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> | |
</HashRouter> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment