Currently, I am working with a list of names obtained from an array using the Fetch method. I have implemented a searchHandler method which is triggered by a button click, and it logs the input data in the console:
https://codesandbox.io/s/jovial-lovelace-z659k
However, I am facing an issue where I want to enter a specific "First name" in the input field, click the button, and only display the line corresponding to that name. Unfortunately, I am struggling to implement the necessary filter logic.
I came across a potential solution online, but I am unable to seamlessly integrate it into my existing code. Here's the snippet:
getFilteredData() {
if (!this.state.search){
return this.state.data
}
return this.state.data.filter(item=>{
return item["firstName"].toLowerCase().includes(this.state.search.toLowerCase())
});
}
Can you guide me on how to incorporate this filter logic into my code? What modifications should I make in the render method?