Skip to content

Instantly share code, notes, and snippets.

@adityapatnaik
Created October 9, 2020 11:56
Show Gist options
  • Save adityapatnaik/a39b19f03c02f38f6abb2039901bc432 to your computer and use it in GitHub Desktop.
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.
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