import React , { FC , useState , useEffect } from 'react' ; import MainContainer from './containers/MainContainer' ; import { BrowserRouter as Router , Route , Switch , Link , Redirect } from "react-router-dom" ; import Connect from './containers/Connect' ; const App = props => { const [ connected , setConnected ] = useState ( false ) ; const connectedHandler = ( ) => { setConnected ( true ) ; } ; useEffect ( ( ) => { console . log ( "in useEffect line 14 of app.tsx" ) ; fetch ( '/checkCookie' ) . then ( response => response . json ( ) ) . then ( data => { if ( data . connected === true ) { connectedHandler ( ) ; } } ) . catch ( ( err ) => { console . log ( err ) ; } ) ; } ) ; if ( connected == true ) { console . log ( "hello from line 29 in app.tsx" ) ; fetch ( '/checkCookie' ) . then ( response => response . json ( ) ) . then ( data => { if ( data . connected === true ) { connectedHandler ( ) ; } } ) . catch ( ( err ) => { console . log ( err ) ; } ) ; } return ( < Router > { connected ? < Redirect to = '/' / > : < Redirect to = "/connect" / > } < Switch > < Route exact path = "/connect" component = { ( ) => < Connect connectedHandler = { connectedHandler } />}/ > < Route exact path = "/" component = { MainContainer } / > < /Switch> < /Router>); } ; export default App ;