React Router Dom #40
-
H, i'm new in Electron and I would like how can I use the React Routes to move between screeans, or have another way to do this? |
Beta Was this translation helpful? Give feedback.
Answered by
codesbiome
Oct 2, 2022
Replies: 2 comments
-
React routes can be used with Electron as we use them in typical web applications based on React/Vue etc. import React, { Component } from 'react';
import { MemoryRouter as Router, Route, Link, Switch } from 'react-router-dom';
import Home from './component/home';
import About from './component/about';
import Contact from './component/contact';
import './App.css';
class App extends Component {
render() {
return (
<Router>
<div className="App">
<Link to="/">Home</Link>
<Link to="/about">About Us</Link>
<Link to="/contact">Contact Us</Link>
<Switch>
<Route exact path='/' component={Home}></Route>
<Route exact path='/about' component={About}></Route>
<Route exact path='/contact' component={Contact}></Route>
</Switch>
</div>
</Router>
);
}
}
export default App; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
CTExhb
-
Thanks for responding quickly! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
React routes can be used with Electron as we use them in typical web applications based on React/Vue etc.
Just define the routes in Application component and navigate between route's components using the
MemoryRouter
from react-router-dom.