Skip to content

Commit

Permalink
Refactor PrivateRoute prop types
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Apr 19, 2021
1 parent 72b3c0d commit 7fe997e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/PrivateRoute/PrivateRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import PropTypes from "prop-types";
import { Route, Redirect } from 'react-router-dom';
import { useLogin } from "../AuthProvider/";

export default function PrivateRoute({ children, ...rest }) {
export default function PrivateRoute({ children, path, ...rest }) {
const isLoggedIn = useLogin();

return (
<Route {...rest}>
<Route path={path} {...rest}>
{
isLoggedIn
? children
Expand All @@ -18,6 +18,8 @@ export default function PrivateRoute({ children, ...rest }) {
};

PrivateRoute.propTypes = {
/** The route's path. */
/** The children to be rendered if a user is logged in. */
"children": PropTypes.node.isRequired,
/** The path to protect */
"path": PropTypes.string.isRequired
};

0 comments on commit 7fe997e

Please sign in to comment.