7
Don’t use the conditional operator here, just assign showLoading
to isLoading
, assuming you’re passing a boolean:
this.isLoading = showLoading;
If you’re not necessarily passing a boolean, then cast to boolean first (if needed):
this.isLoading = Boolean(showLoading);
If you had to use the conditional operator, it would be:
this.isLoading = showLoading ? true : false;
1
fetchData(showLoading) {
showLoading ? (this.isLoading = true) : (this.isLoading = false)
}
0
your ‘showLoading’ data is I guess Boolean and you dont need if else.
this.isLoading = showLoading
and it’s wrong below code will get error
this.isLoading = showLoading ? true : false;
0
It looks like you want to force showLoading to be a Boolean so try this
this.isLoading = !!showLoading;
Source:stackexchange.com