I learn React and now I'm completely stuck on this ridiculous error.
Here's an image and down below the code, what am I doing wrong?
import React from 'react';
import { useNavigate } from 'react-router-dom';
import AuthUserContext from './context';
const WithAuthorization = condition => Component => {
class withAuthorization extends React.Component {
constructor() {
super();
this.navigateAway = this.navigateAway.bind(this);
}
navigateAway() {
const navigate = useNavigate();
navigate('/');
}
render() {
return (
<AuthUserContext.Consumer>
{authUser => (condition(authUser) ? <Component {...this.props} /> : { this.navigateAway })};
</AuthUserContext.Consumer>
);
}
}
return withAuthorization;
};
export default WithAuthorization;
Update
Thanks to @antoineso answer I removed the {} braces and then it stopped complaining but I then get an ever stranger error: