Skip to content

Instantly share code, notes, and snippets.

@richellyitalo
Last active September 27, 2018 01:28
Show Gist options
  • Save richellyitalo/2562bbac5d3273d2ad862b1c900de23c to your computer and use it in GitHub Desktop.
Save richellyitalo/2562bbac5d3273d2ad862b1c900de23c to your computer and use it in GitHub Desktop.
Recebendo props via redux e alterando o state do componente
// 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