Social Network for Pets, Task 2 and 4 HELP!

There are several things I have hard time understanding in ‘Social Network for Pets’ Practice.

Task 2 tells to set the userData state to null while the data is Loading. I assumed the right way to code was

if (isLoading){
this.setState({ userData : null });

But I realized you just call this.setState{( userData: null)} without any condition. Why is that?


Task 4 tells variable isLoading should be true only when this.state.userData is null.
Concise way to do this is to code it like below:

const isLoading = this.state.userData === null ? true : false;

But i thought it should work the same way if I code it like below, but it did not. How come?

const isLoading;
if (this.state.userData === null ) {
 isLoading = true;
isLoading = false;

Not really sure about the first one but in the Question 2 you probably just need to set is Loading to let instead of const since you are changing the value.

const isLoading → let isLoading