Last active
September 27, 2018 01:28
-
-
Save richellyitalo/2562bbac5d3273d2ad862b1c900de23c to your computer and use it in GitHub Desktop.
Recebendo props via redux e alterando o state do componente
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imports | |
class Login extends Component { | |
state = { | |
email: '', | |
password: '', | |
errors: {} | |
} | |
componentDidMount() { | |
if (this.props.auth.isAuthenticated) { | |
this.props.history.push('/dashboard') | |
} | |
} | |
componentWillReceiveProps(nextProps) { | |
if (nextProps.auth.isAuthenticated) { | |
this.props.history.push('/dashboard') | |
} | |
if (nextProps.errors) { | |
this.setState({ errors: nextProps.errors }) | |
} | |
} | |
// ... | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment