score:0

useEffect(() => {
  filterCompany()
}, []);

score:0

  const [filters, setFilter] = useState([])

  function addOrRemoveFilter(item) {
    if (filters.includes(item)) {
      const filteredItems = filters.filter(filteredItem => filteredItem !== item)
      setFilter([...filteredItems])

    } else {
      setFilter([...filters, item])
    }
  }

  function filterCompany() {
    const res = company.filter(comp => {
      return filters.every(filter => {
        return comp.tags.includes(filter)
      })
    })
    return filters.length === 0 ? company : res
  }

  const companies = useMemo(() => filterCompany, [filters]);

score:1

{getFilteredCompanies().map((item, index) => <span key={index}>{item.name}</span>)}

Related Query

More Query from same tag