How can I pass parameters to all my routes through <Routes />
?
This is my Routes.js.
import React, { Component } from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import Repos from './Repos';
import Org from './Org';
import Profile from './Profile';
class Routes extends Component {
render() {
return (
<Switch>
<Route exact path="/" render={() => (
<Redirect to='/profile' />
)} />
<Route exact path="/profile" component={Profile} />
<Route exact path="/repos" component={Repos} />
<Route exact path="/org" component={Org} />
</Switch>
);
}
}
export default Routes;
This is how I am calling the routes component from Dashboard.js.
import React from 'react';
import Routes from './Routes';
import Header from './Header';
const Dashboard = props => {
return (
<div>
<Header />
<Routes />
</div>
);
};
export default Dashboard;
I need to pass common props to all my routes through <Routes />
. How can i do it?