'Manipulation in Filtering multiple inputs in React

I have two date inputs and one select tag to filter data in a datatable. After collecting the data and storing it in a variable, I want to create a new variable filteredItems, to make the manipulation, the problem is that when the two date inputs are null or select input is null it will filter input as "" and it is zero data, how to make a check inside the filteredItem to make the correct filtration.

const [data, setData] = useState([]);
const [type, setType] = React.useState("");
const [startDate, setStartDate] = React.useState(null);
const [endDate, setEndDate] = React.useState(null);

useEffect(() => {
    const data = await axios(`url`);

    setData(data);

  }, []);


const filteredItems = data.filter(
    (item) =>
      item.startDate >= startDate &&
      item.endDate <= endDate &&
      item.type == type
  );

return (
<>
 <DataTable
    data={filteredItems} />
</>
    )


Solution 1:[1]

      const filteredData = absencesData.filter((item) =>
    !startDate && !endDate && !type
      ? true
      : !startDate && !endDate && type
      ? item.type === type
      : startDate && endDate && !type
      ? item.startDate >= startDate && item.endDate <= endDate
      : startDate && endDate && type
      ? item.startDate >= startDate &&
        item.endDate <= endDate &&
        item.type === type
      : true
  );

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 n9p4