mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 21:25:04 +00:00
Still working on Auth State
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
import React from 'react'
|
||||
import { Route, Redirect} from 'react-router-dom';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const AuthRoute = ({ component: Component, authenticated, ...rest}) => (
|
||||
const AuthRoute = ({ component: Component, authenticated, ...rest }) => (
|
||||
<Route
|
||||
{...rest}
|
||||
render = {(props) => authenticated === true ? <Redirect to='/home'/> : <Component {...props} />}
|
||||
render={(props) =>
|
||||
authenticated === true ? <Redirect to='/home'/> : <Component {...props} />}
|
||||
/>
|
||||
)
|
||||
);
|
||||
|
||||
export default AuthRoute;
|
||||
const mapStateToProps = (state) => ({
|
||||
authenticated: state.user.authenticated
|
||||
});
|
||||
|
||||
AuthRoute.propTypes = {
|
||||
user: PropTypes.object
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(AuthRoute);
|
||||
|
||||
Reference in New Issue
Block a user