DEV Community

Discussion on: Search Bar in React JS!

Collapse
 
crsandeep24 profile image
Sandeep Reddy

What if no search results? How can we display a 'No results found' error?

Collapse
 
salehmubashar profile image
Saleh Mubashar

We can check the length of the filteredData array. If it is less than 1 then no results.

if (filteredData.length < 1) {
   // something
}
Enter fullscreen mode Exit fullscreen mode