Если я правильно понял. Попробуйте:
// app.js
import React from 'react';
import {Switch, Route, withRouter} from 'react-router-dom';
import './App.css';
import Sidebar from './components/Sidebar';
import AppBar from './components/Appbar';
import Home from './pages/Home';
import Blog from './pages/Blog';
const App = (props) => {
const pathname = props.location;
// Just show up with this routes
const configRoutes = ['/', '/about'];
const checkPath = configRoutes.includes(pathname);
return(
<div className="App">
{
checkPath && (<Appbar />
<Sidebar />)
}
<Switch>
<Route path="/" exact component={Home} />
<Route path="/blog" exact component={Blog} />
</Switch>
</div>
);
}
export default withRouter(App);