, . , , "", .
"" . Redux
connect HOC. . , , localStorage .. :
import React from 'react'
export default function(ComposedComponent) {
class RequireAuth extends Component {
state = {
isAuthenticated: false
}
componentWillMount() {
if(!this.state.authenticated) {
}
}
componentWillUpdate(nextProps) {
if(!this.state.authenticated) {
}
}
render() {
return <ComposedComponent {...this.props}/>
}
}
return RequireAuth
}
HOC RequireAuth - , :
<Route exact path='/' component={RequireAuth(Home)} />
: , RequireAuth, . RequireAuth isAuthenticated true. , - . connect HOC , isAuthenticated .