Advertisement
Shell_Casing

App.js - main app component

Oct 10th, 2020
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useEffect } from 'react';
  2. import { useDispatch } from "react-redux";
  3. import { BrowserRouter } from 'react-router-dom';
  4. import { Routes } from "./routes/routes";
  5. import { AlertNotifications } from "./components/alert/alert";
  6. import { Navbar } from "./components/navbar/navbar";
  7. import { SelectDropdownsState } from "./context/select-dropdowns";
  8. import { renewAuthTokenAction } from "./store/actions/authActions";
  9. import './App.css';
  10.  
  11. const App = () => {
  12.  
  13.     const dispatch = useDispatch();
  14.  
  15.     const renewToken = async () => await dispatch(renewAuthTokenAction());
  16.  
  17.     let renewTokenID;
  18.  
  19.     const fiveMinuteTimer = () => renewTokenID = setInterval(renewToken, 300000);
  20.  
  21.     useEffect(() => {
  22.         fiveMinuteTimer();
  23.  
  24.         return () => clearInterval(renewTokenID);
  25.     }, []);
  26.  
  27.  
  28.     return (
  29.         <BrowserRouter>
  30.             <div className="mb-10 mx-auto">
  31.                  <Navbar />
  32.             </div>
  33.             <SelectDropdownsState>
  34.               <div className="container w-full mx-auto my-4 py-4">
  35.                   <AlertNotifications />
  36.                   <Routes />
  37.               </div>
  38.             </SelectDropdownsState>
  39.         </BrowserRouter>
  40.     );
  41.  
  42. };
  43.  
  44. export default App;
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement