I am working on project in ReactJS, I am fetching data from server through API. I did some search filtration, I want to display message if there is no records available? I a
You could check for the data before render the component and return another component if you don't have any. Using expressions such This example ‘’’ { doIHaveData ? < Component1 /> : < Component2 />} ‘’’
Where Component1 has your functionality and Component2 return a message or a spinner loader whatever you want .
I hope it helps!
When you are checking for the empty array you could check for array type and length. I would personally do something like
{Array.isArray(array) && array.length === 0 ? : }