React Component check is variable is empty
render() {
return (
<div>
<div>{!!(this.myvar)?this.myvar:"whatever you want"}</div>//
</div>
);
}
!!: check for undefined, null, and empty value
The provided solution runs afoul of eslint's no-extra-boolean-casts rule.
An alternate method that makes eslint happy would look like this:
render() {
return (
<div>
<div>{!this.myvar ? "whatever you want" : this.myvar}</div>//
</div>
);
}