How to search for more than one item with .filter()

How can I make it so i can search for more than one item. Right now I have it so it can only search for name, and I want to be able to search for id and name.

I’ve tried multiple solutions for example this:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter without success.

CODE:

const [search, setSearch] = useState('');
  const [masterDataSource] = useState(DataBase);

  const filteredDataSource = masterDataSource.filter((item) => {
    return item.name.includes(search);
  });

return(
<TextInput
   onChangeText={(text) => setSearch(text)}
   value={search}
 />
)

.

DataBase

{
    id: '1234567788900',
    name: 'AWD',
    company: 'HALDEX',
  },

27 thoughts on “How to search for more than one item with .filter()”

  1. 307169 377661I located your weblog site on google and check a couple of of your early posts. Proceed to sustain up the quite excellent operate. I just extra up your RSS feed to my MSN News Reader. Seeking for ahead to reading extra from you later on! 414015

    Reply
  2. 928134 636866A lot of writers recommend just writing and composing no matter how bad and if the story is going to develop, you will suddenly hit the zone and itll develop. 776563

    Reply

Leave a Comment