Answer the question
In order to leave comments, you need to log in
How to make an array filter in React with search and parameters?
There is an array of phones and laptops.
{
"id": 1,
"category": "notebooks",
"brand": "lenovo",
"title": "Ноутбук Lenovo G50-30",
},
{
"id": 2,
"category": "notebooks",
"brand": "lenovo",
"title": "Ноутбук Lenovo G70-35",
},
{
"id": 10,
"category": "phones",
"brand": "samsung",
"title": "Смартфон Samsung Galaxy S7 32GB Black Onyx",
},
{
"id": 11,
"category": "phones",
"brand": "samsung",
"title": "Смартфон Samsung Galaxy A3 (2016) Black",
}
let filteredData = this.state.data.filter((item) =>{
return item.title.toLowerCase().indexOf(this.props.filterToChild) !== -1;
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question