Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
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} />
</>
    )
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

      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
  );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!