SHARE
TWEET

Untitled

a guest Jul 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2. import { BrowserRouter as Router, Route } from "react-router-dom";
  3. import { Provider } from "react-redux";
  4. import PropTypes from "prop-types";
  5. import createHistory from "history/createBrowserHistory";
  6.  
  7. //Components
  8. import LoginForm from "../LoginForm/LoginForm";
  9. import PrivateRoute from "../PrivateRoute/PrivateRoute";
  10. import ServerList from "../ServerList/ServerList";
  11.  
  12. const App = ({ store }) => {
  13.   const isLoggedIn = localStorage.getItem("userToken");
  14.   const history = createHistory();
  15.  
  16.   return (
  17.     <Router history={history}>
  18.       <Provider store={store}>
  19.         <div className="App">
  20.           {isLoggedIn !== true && <Route path="/login" component={LoginForm} />}
  21.           <PrivateRoute
  22.             isLoggedIn={!!isLoggedIn}
  23.             path="/"
  24.             component={ServerList}
  25.           />
  26.         </div>
  27.       </Provider>
  28.     </Router>
  29.   );
  30. };
  31.  
  32. App.propTypes = {
  33.   store: PropTypes.object.isRequired
  34. };
  35.  
  36. export default App;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top