educative.io

Ternary Operator in React

why const showuser is used. what is the use of this showuser .
react showuser


Type your question above this line.

Course: https://www.educative.io/collection/10370001/5637225408626688
Lesson: https://www.educative.io/collection/page/10370001/5637225408626688/5074275455205376

Hey @rishabh_verma!
This lesson is about conditional rendering. The list of usernames is rendered using the if condition. The const showUsers = true; makes the condition true, so the list is displayed on the screen. If we set the const showUsers = false; the list will not be displayed on the screen because of this condition:

if (!showUsers) {
return null;
}

So the showUser is a flag for rendering condition.