I need to change the language of the message sent in accordance with the browser's language when I want to reset the password in my app. This is my onSubmit func, which i call on submit form to send message. I take value from state and put it into languageCode. I use redux
onSubmit = () => {
let error = {}
if (!this.state.email)
error.email = <FormattedMessage id='common.error.empty' />
if (Object.keys(error).length) {
this.setState({error})
return
}
this.props.languageCode(this.props.locale)
this.props.doPasswordReset(this.state.email).then(() => {
this.setState({openDialog: true})
}).catch(error => {
this.setState({
error: {
...this.state.error,
email: error.message,
},
})
})
}