Live Search Filter

Easy
Free
#Forms and Inputs

Build a live search over a list of fruits: as you type in the Search field, the list narrows to the fruits that match, and a "No results found" message takes its place when nothing does. You'll practice controlling an input with useState and working out what to show from that state on every render. The starter has the FRUITS list to search, and the page's Search field, Clear button and "No results found" message.

Requirements

  • At first the page lists every fruit in FRUITS, and the "No results found" message isn't shown.
  • Typing in the Search field narrows the list on every keystroke to the fruits whose name contains the text anywhere, ignoring upper and lower case. For example, an shows Banana, Mango and Orange.
  • The Search field always shows exactly what was typed. Deleting letters brings fruits back, and an empty field lists every fruit again.
  • When no fruit matches, the "No results found" message shows instead of the list. While any fruit matches, the message isn't shown.
  • Clicking Clear empties the Search field and lists every fruit again.

React docs

Concepts you'll practice

Live Search Filter — React Coding Challenge | React Interview Prep