title: How to protect one admin page with react-router-dom v4?
body: <p>I'm creating a website with different pages. It uses React.js in the front-end and Express in the back-end. Basically it is a MERN-stack. </p>
  
  <p>For navigation i use react-router-dom v4. Routing works like a charm. Now i have to protect one page. I've tried with the reacttraining.com documentation, but without succes. </p>
  
  <p>My App.js: </p>
  
  <pre><code>import React from 'react';
  import { BrowserRouter as Router, Route, Switch, Redirect } from 
  'react-router-dom';
  import createBrowserHistory from 'history/createBrowserHistory';
  
  const history = createBrowserHistory();
  
  import Home from './Home.jsx';
  import Intro from './IntroVideo.jsx';
  import Question from './Question.jsx';
  import FormPage from './FormPage.jsx';
  import Dashboard from './AdminPage.jsx'
  import Login from './Login.jsx'
  import NotFound from './NotFound.jsx'
  
   export default class App extends React.Component{
     constructor() {
       super();
       this.state = {
         redirectTo: null
       }
       this.checkAuth = this.checkAuth.bind(this);
     }
     checkAuth(){
       this.setState({
         redirectTo: '/login'
       });
     }
     render() {
       return (
         &lt;Router history={history}&gt;
      &lt;Switch&gt;
        &lt;Route exact path="/" component={Home}/&gt;
        &lt;Route exact path="/intro" component={Intro}/&gt;
        &lt;Route exact path="/question" component={Question}/&gt;
        &lt;Route exact path="/form" component={FormPage} /&gt;
        &lt;Route exact path="/dashboard" component={Dashboard} onEnter=
  {this.checkAuth} /&gt;
        &lt;Route exact path="/login" component={Login} /&gt;
        &lt;Route component={NotFound} /&gt;
      &lt;/Switch&gt;
    &lt;/Router&gt;
       )
     }
   }
  </code></pre>
  
  <p>What is the correct solution for my problem?
  '/dashboard' needs to be protected and only be seen if you are logged in.</p>
  
  <p>Thx for the help;)</p>