You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
504 B
30 lines
504 B
import React from "react"; |
|
import { Route, Redirect } from "react-router-dom"; |
|
import { connect } from "react-redux"; |
|
|
|
const PrivateRouter = ({ |
|
component: Component, |
|
restricted, |
|
status, |
|
...rest |
|
}) => { |
|
return ( |
|
<Route |
|
{...rest} |
|
render={(props) => |
|
true ? ( |
|
<Component {...props} /> |
|
) : ( |
|
<Redirect to="/" /> |
|
) |
|
} |
|
/> |
|
); |
|
}; |
|
|
|
export default connect( |
|
(state) => ({ |
|
status: state.user.status, |
|
}), |
|
{} |
|
)(PrivateRouter);
|
|
|