Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda