Login failure not handled gracefully

I can see that we are entering the catch block but then I get a runtime exception.
} catch (ex) {
if (ex.response && ex.response.status === 401) {
const errors = { …this.state.errors };
errors.username = ex.response.data;
console.log(errors);
this.setState({ errors });
}


{
“username”: {
“detail”: “No active account found with the given credentials”
}
}

Uncaught Error: Objects are not valid as a React child (found: object with keys {detail}). If you meant to render a collection of children, use an array instead.
… stack trace …
The above error occurred in the

component:

at div
at div
at Input (http://localhost:3000/static/js/main.chunk.js:4467:5)
at form
at div
at LoginForm (http://localhost:3000/static/js/main.chunk.js:6004:5) My code in the catch block is almost the same as in the course.