I am new in React JS and I want to check the actual route using React Router. This is the entry point:
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<div>
<HeaderControl />
<MuiThemeProvider>
<Switch>
<Routes />
<PrivateRoute path="/" component={Home} />
</Switch>
</MuiThemeProvider>
<Footer />
</div>
</ConnectedRouter>
</Provider>,
document.getElementById('app'),
);
The main goal is rendering a conditional component called Title inside of my Home component. This is my Home component:
import React, { Component } from 'react';
import { Title } from '../Titles/titles';
class Home extends Component {
render() {
return (
<div className="container-view">
<div className="container-view-inside">
<Title />
</div>
</div>
);
}
}
export { Home as default, Title };
The condition is that if the actual url is /home for example, the title is Title1 and if the actual url is /other the title is Title2. The problem is that I do not know how to check the actual path and then, build the Title Component.
Thanks.