text: import React from 'react';
  import PropTypes from 'prop-types';
  import { connect } from 'react-redux';
  import { Route, Redirect } from 'react-router-dom';
  import Header from '../components/Header';
  
  export const PrivateRoute = ({
    isAuthenticated,
    component: Component,
    ...rest
  }) => (
    <Route
      {...rest}
      component={props => ( // props -> history(instance of createBrowserHistory())
        isAuthenticated ? (
          <div>
            <Header />
            <Component {...props} />
          </div>
        ) : (
          <Redirect to="/" />
        )
      )}
    />
  );
  
  const mapStateToProps = state => ({
    isAuthenticated: !!state.auth.uid
  });
  
  PrivateRoute.propTypes = {
    isAuthenticated: PropTypes.bool.isRequired,
    component: PropTypes.element.isRequired
  };
  
  export default connect(mapStateToProps)(PrivateRoute);
  