React Schedule Not Updating When Datasource Updates

I'm working with the ScheduleComponent in React.   The Schedule component displays scheduleEvents as I would expect using eventSettings{{datasource:}} But when the parent component receives new props the parent component sees the props are new, but ScheduleComponent never updates and if I console.log the ScheduleComponent.eventSettings.datasource... the datasource is now the first datasource passed to it, not the updated values.

The change is a timestamp, but even when I change something like a string {description: 'cat'} the ScheduleComponent never updates.

Note that the parent component is a React function component, if I render the scheduleEvents manually in that components, they update just fine.    Any ideas?

                    <ScheduleComponent
                        ref={t => scheduleObj = t}
                        eventSettings={{ dataSource: scheduleEvents }}
                        cellClick={(event=> onCellClick(event)}
                        editorTemplate={(event=> ApptEditorTemplate(event)}
                        popupOpen={(event=> onPopupOpen(event)}
                        actionBegin={(event=> actionBegin(event)}
                    >

3 Replies 1 reply marked as answer

HB Hareesh Balasubramanian Syncfusion Team March 2, 2021 12:22 PM UTC

Hi Mark, 

Greetings form Syncfusion Support..! 

We have validated your shared query at our end and suspect that your requirement is to ‘render the events of the Scheduler using state change’ and for that same, we have prepared a sample, which can be viewed from the following link. 


  componentDidMount() { 
    let data = extend( 
      [], 
      dataSource.scheduleData.concat(dataSource.timelineData), 
      null, 
      true 
    ); 
 
    let that = this; 
    setTimeout(() => { 
      that.setState({ 
        data 
      }); 
    }, 2000); 
  } 

  render() { 
    const { data } = this.state; 
    return ( 
      <div className="schedule-control-section"> 
        <div className="col-lg-9 control-section"> 
          <div className="control-wrapper"> 
            <ScheduleComponent 
              delayUpdate="true" 
              height="650px" 
              ref={schedule => (this.scheduleObj = schedule)} 
              selectedDate={new Date(2019, 0, 10)} 
              eventSettings={{ dataSource: data }} 
            > 
              <ViewsDirective> 
                <ViewDirective option="TimelineDay" /> 
                <ViewDirective option="TimelineWeek" /> 
                <ViewDirective option="TimelineWorkWeek" /> 
                <ViewDirective option="TimelineMonth" /> 
              </ViewsDirective> 
              <Inject 
                services={[ 
                  TimelineViews, 
                  TimelineMonth, 
                  Agenda, 
                  Resize, 
                  DragAndDrop 
                ]} 
              /> 
            </ScheduleComponent> 
          </div> 
        </div> 
      </div> 
    ); 
  } 

In the above sample, data of the scheduler is refreshed properly, can you please replicate the issue in the above sample or share code snippet that how you have changed the scheduler. 

We will happy to assist you..! 

Regards, 
Hareesh 



MA Mark March 2, 2021 04:59 PM UTC

Thank you for your reply Hareesh.

I reproduced your code and in that example I saw it update. 

I also created something more like my code where the state changed in a parent component and the data was passed down via props, and again the ScheduleComponent updated.    That all makes sense.

However, my 
ScheduleComponent in other code is not updating.  So it must be something I'm doing, although there's not much different in my code from the examples.

Then I added 
delayUpdate to my ScheduleComponent and it updated ... it doesn't seem to matter if I add delayUpdate="true" or delayUpdate="false", either way without using delayUpdate it fails to update in my code, and with delayUpdate it does update.

Ultimately in my code I'm calling an API for updates every few minutes, that returns scheduleEvents  and those events are passed as props through a hook and on through some other components down to the component holding the ScheduleComponent.  The last component that contains ScheduleComponent  sees the changes, but ScheduleComponent doesn't update without setting delayUpdate.   

What does delayUpdate actually do?

I'm having trouble finding it in the documentation.



NR Nevitha Ravi Syncfusion Team March 3, 2021 09:08 AM UTC

Hi Mark, 

Thanks for your update. 

The delayUpdate delays the component rendering after the state has changed, please refer to the following link to know about delayUpdate. 

If you still face any issue kindly share the issue details or replicate the issue in a sample to help you out. 

Regards, 
Nevitha 


Marked as answer
Loader.
Up arrow icon