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

291
Vistas
React Calendar Timeline doesn't show fetched data

So I came to cross the problem. It is weird that the React-Calendar-Timeline component doesn't show fetched items even I know it is in the array. However, when I open inspect element, the items render as it should and everything is starting to work.

I tried solving the problem by implementing loading screen while the data is fetching, however, the problem stays the same.

Here is the timeline component code:

{!isLoading ? (
            <CalendarContainer>
              <Timeline
                groups={rooms}
                items={tenantsInCalendar} // this part is not rendering at the first time
                defaultTimeStart={startDate}
                defaultTimeEnd={endDate}
                canResize={"both"}
                stackItems
                onItemSelect={handleItemClick}
                onItemDeselect={() => dispatch(setCurrentTenant(null))}
                minZoom={24 * 60 * 60 * 1000} // min zoom is 24 hours.
                dragSnap={24 * 60 * 60 * 1000} // snap is at 24 hours.
                canMove={true}
                itemHeightRatio={0.75}
                onItemMove={handleItemMove}
                onItemResize={handleItemResize}
                timeSteps={{
                  day: 1,
                  month: 1,
                  year: 1,
                }}
              ></Timeline>
            </CalendarContainer>
          ) : (
            <Spinner />
          )}

The fetching methods:

  useEffect(() => { // converting fetched data to object for better/faster properties changement
    fetchedTenants &&
      setTenantsToObject(convertTenantsToObject(fetchedTenants));
  }, [fetchedTenants]);

  useEffect(() => { // converting tenants to other object type for calendar to understand. This data is rendered in calendar component.
    tenantsToObject &&
      setTenantsInCalendar(
        convertTenantsToCalendarObjectItems(Object.values(tenantsToObject))
      );
  }, [tenantsToObject]);

  useEffect(() => {
    if (tenantsInCalendar.length > 0 && isLoading) {
      handleTimeout(1000);
    }
  }, [tenantsInCalendar]);

  const handleTimeout = (time) => { // sets some timeout for calendar to really render data at the first time. However, still doesn't work as it should.
    setTimeout(() => {
      setIsLoading(false);
    }, time);
  };

Also, I'm adding photos, from which the first one is at the first render. The second one is when I open inspect element tool. enter image description here enter image description here

about 4 years ago · Juan Pablo Isaza
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