I am trying to check if a prop is empty and add a condition to a react component.
Here is the code:
class Mycomp extends Component {
render() {
return (
<div className="Mycomp">
{this.props.title}
if (this.props.title != '') {
console.log('Title is not empty');
}
</div>
);
}
}
The problem is that I'm getting an Unexpected Token error.
How can I fix this?