search from array of objects

 const searchFilterFunction = (text) => {

// Check if searched text is not blank

if (text) {
// Inserted text is not blank
// Filter the masterDataSource
// Update FilteredDataSource
const newData = masterDataSource.filter(function (item) {
const itemData = item.id
? item.id.toUpperCase()
: ''.toUpperCase();
const textData = text.toUpperCase();
return itemData.indexOf(textData) > -1;
});
setFilteredDataSource(newData);
set_email(text);
} else {
// Inserted text is blank
// Update FilteredDataSource with masterDataSource
setFilteredDataSource(masterDataSource);
set_email(text);
}
};

Comments

Popular posts from this blog

Simple Redux

Add Axios Interceptor in Services where Api is called

React Interview Questions