text: import PropTypes from 'prop-types';
  import { useSelector } from 'react-redux';
  import { Route, Redirect } from 'react-router-dom';
  import { authSelectors } from 'redux/auth';
  
  export default function PublicRoute({
    children,
    restricted,
    redirectTo,
    ...routeProps
  }) {
    const isLoggedIn = useSelector(authSelectors.getIsLoggedIn);
    const shouldRedirect = isLoggedIn && restricted;
    return (
      <Route {...routeProps}>
        {shouldRedirect ? <Redirect to={redirectTo} /> : children}
      </Route>
    );
  }
  
  PublicRoute.defaultProps = {
    restricted: false,
    redirectTo: '/',
  };
  
  PublicRoute.propTypes = {
    children: PropTypes.node,
    restricted: PropTypes.bool,
    redirectTo: PropTypes.string,
    routeProps: PropTypes.any,
  };
  