React
75
Вклад в тег
class ProtectedRoute extends Component {
render() {
const {component, ...rest} = this.props
return <Route {...rest} render = {this.getComponent}/>
}
getComponent = (...args) => {
return this.props.user && this.props.access.indexOf(this.props.user.role) !== -1 ? <Main title={this.props.title} ><this.props.component {...args} /></Main> :
<ErrorPage/>
}
}
export default connect(state => ({
user: userSelector(state)
}), null, null, { pure: false })(ProtectedRoute)
yield put({
type: BEGIN_FETCHING
})
yield put({
type: END_FETCHING
})