text: import React, { Component } from "react";
  import "./App.css";
  import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
  import { Provider } from "react-redux";
  import store from "./store";
  import jwt_decode from "jwt-decode";
  import setAuthToken from "./utils/setAuthToken";
  import { setCurrentUser, logoutUser } from "./actions/userActions";
  
  //Importing custom made components
  import NavBar from "./components/layout/NavBar";
  import Landing from "./components/landing/Landing";
  import Diary from "./components/diary/Diary";
  
  import Login from "./components/auth/Login";
  import Signup from "./components/auth/Signup";
  
  
  if (localStorage.jwtToken) {
    //Set auth token header auth
    setAuthToken(localStorage.jwtToken);
    //Decode token and get user info and expiration
    const decoded = jwt_decode(localStorage.jwtToken);
    //Set user and isAuthenticated
    store.dispatch(setCurrentUser(decoded));
  
    //Check for expired token
    const currentTime = Date.now() / 1000;
    if (decoded.exp < currentTime) {
      store.dispatch(logoutUser());
    }
  }
  
  
  class App extends Component {
    render() {
      return (
        <Provider store={store}>
          <Router>
            <div>
              <NavBar />
              <Switch>
                <Route exact path="/" component={Landing} />
                <Route exact path="/diary" component={Diary} />
                <Route exact path="/login" component={Login} />
                <Route exact path="/signup" component={Signup} />
              </Switch>
            </div>
          </Router>
        </Provider>
      );
    }
  }
  
  export default App;
  