import * as React from "react" ; import { Route , Redirect , Switch , withRouter } from "react-router-dom" ; import Home from "./Home/Home" ; import BoardContainer from "./Board/BoardContainer" ; import LandingPage from "./LandingPage/LandingPage" ; import "./App.scss" ; import { watch , state } from "../model" ; const App = ( { } ) => { const user = watch ( state . userId ) ; if ( user ) { return ( < Switch > < Route exact path = "/" component = { Home } / > < Route path = "/b/:boardId" component = { BoardContainer } / > < Redirect to = "/" / > < /Switch>); } else { return ( < Switch > < Route exact path = "/" component = { LandingPage } / > < Redirect to = "/" / > < /Switch>); } } ; export default withRouter ( App ) ;