From 7fe997e4445673d32f9298cb36be10bc8f81e05e Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Sun, 18 Apr 2021 23:49:26 -0400 Subject: [PATCH] Refactor PrivateRoute prop types --- src/components/PrivateRoute/PrivateRoute.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/PrivateRoute/PrivateRoute.js b/src/components/PrivateRoute/PrivateRoute.js index 9a7ebad..390b0b4 100644 --- a/src/components/PrivateRoute/PrivateRoute.js +++ b/src/components/PrivateRoute/PrivateRoute.js @@ -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 ( - + { isLoggedIn ? children @@ -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 }; \ No newline at end of file