React/ Chakra/Spinner

Dear All

I want to use spinner in my code for being showed while fetching data

I code it in 2 different ways but in 1 way the code worked.

does any body know what is wrong with another method?

I’d think you’d have to say loading === true …

it did not work because second expression typically and only uses inside tsx elements



1 Like

also, there’s no return statement in second expression

it is fine. in javascript it is considered as you are checking a truthy value.

const isLoading = true;
const isLoading = ‘something value here’;

if(loading) {
it will go here because loading is a truthy value, or has value.

1 Like

Thanks , yeah I get that

The second way not work because the component dont have return after execute

hi, yes I didnt check that before . when i code the line after return the second way works too