Router.js
863 Bytes
import React from "react";
import PropTypes from "prop-types";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import Auth from "./Auth/AuthContainer";
import Home from "../Components/Home";
const LoggedInRoutes = () => (
<>
<Route exact path="/" component={Home} />
<Route exact path="/OTOChat" component={Home} />
<Route exact path="/RandomChat" component={Home} />
<Route exact path="/CategoryChat" component={Home} />
<Route exact path="/Profile" component={Home} />
</>
);
const LoggedOutRoutes = () => (
<>
<Route exact path="/" component={Auth} />
</>
);
const AppRouter = ({ isLoggedIn }) => (
<Router>
<Switch>{isLoggedIn ? <LoggedInRoutes /> : <LoggedOutRoutes />}</Switch>
</Router>
);
AppRouter.propTypes = {
isLoggedIn: PropTypes.bool.isRequired,
};
export default AppRouter;