Answer the question
In order to leave comments, you need to log in
How to make a condition to check the value in props?
Hello everyone, I have props in which the value is transferred from the json file at the request of the user. Or rather, he enters the full name, if there is no full name, then an error should be displayed, saying that there is no such user.
I write condition:
if (items ?????) {
return <div>...</div>
}
Answer the question
In order to leave comments, you need to log in
If (items.length) { ... }
Because if (items) will turn items into a "boolean", and will first turn into an Object! (all arrays are objects), and the object is TRUE
But empty_array.length will return 0, which means FALSE
Or did I misunderstand your question? specify.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question