Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

108
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda