Uncaught TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')

Dear Syncfisuion team,

I am working on a Appointment scheduing app using Syncfusion scheduling components. In my "editorTemplate" I am using the DateTimePickerComponent with the eventListener "created" and "onChange". When clicking on a cell and scheduling a Appointment everything works the first time, but if a want to schedule a second time the Programm crashes and I get following error:


If I run without the "created" eventlistener, everything works fine, but my goal is to store the Form Data in an Object using "useState" and I want to set the state when the DateTimePicker is created and when the value is changed by the user.

Best regards,

Gabriel

Edit: I am currently using the Version 19.3.55

 


6 Replies

VD Vinitha Devi Murugan Syncfusion Team December 6, 2021 12:43 PM UTC

Hi Gabriel, 
 
Greetings from Syncfusion Support. 
 
We have checked your reported issue at our end but since we need additional information to validate the issue, could you please share the following details that help us to provide the solution as soon as possible 
 
  • Scheduler package version
  • Share scheduler and datetimepicker related code snippets
  • Share a video demo depicting the issue
  • Share any issue reproducing sample(if possible)
 
 
Regards, 
Vintiha 



GA Gabriel replied to Vinitha Devi Murugan December 6, 2021 01:57 PM UTC

I am currently using the version 19.3.55, and below you can see the code of the scheduler as well as the editorTemplate:

 SchedulerComponent:

    return (

        <div>

            <ScheduleComponent timeFormat='HH:mm' currentView='Week' weekRule='FirstFullWeek' eventClick={() => { }} cellClick={() => { }}

                showWeekNumber={true} firstDayOfWeek={1} workHours={{ highlight: false }} showQuickInfo={false}

                eventSettings={{ dataSource: appointmentsRequest.response }} editorTemplate={AppointmentComponent}

                views={['Day', 'Week', 'Month', 'Agenda']} >

                <Inject services={[Day, Week, Month, Agenda]} />

            </ScheduleComponent>

        </div >

    )

}


And the editor Template with the DateTimePicker component


export const AppointmentComponent = (props: any) => {

    const [newAppointment, setNewAppointment] = useRecoilState(newAppointmentState)

    const [boatList,]: any = useRecoilState(orgBoatList)


    return (

        <table className='custom-event-editor'>

            <tbody>

                <tr>

                    <td className='e-textlabel'>Type of training</td>

                    <td>

                        <DropDownListComponent id='TypeOfTraining' dataSource={['Rowing', 'Strength training', 'Ergometer training']} className='e-field'

                            placeholder='Choose type of training' onChange={(args: any) => setNewAppointment({ appointment: { ...newAppointment.appointment, Type: args?.value } })} data-name='Type' value={props.EventType || null}>

                        </DropDownListComponent>

                    </td>

                </tr>

                <tr>

                    <td className='e-textlabel'>From</td>

                    <td>

                        <DateTimePickerComponent id='StartTime' data-name='StartTime' format='dd/MM/yyyy HH:mm'

                            value={new Date(props.StartTime)} className='e-field'

                            created={() => { console.log(props.StartTime); setNewAppointment({ ...newAppointment, appointment: { ...newAppointment.appointment, StartTime: new Date(props.StartTime), EndTime: new Date(props.EndTime) } }) }}

                            onChange={(args: any) => { console.log(args); setNewAppointment({ appointment: { ...newAppointment.appointment, StartTime: new Date(args?.value) } }) }} >

                        </DateTimePickerComponent>

                    </td>

                </tr>


                <tr>

                    <td className='e-textlabel'>To</td>

                    <td>

                        <DateTimePickerComponent id='EndTime' data-name='EndTime' format='dd/MM/yyyy HH:mm'

                            value={new Date(props.endTime || props.EndTime)} className='e-field'

                            onChange={(args: any) => { console.log(args); setNewAppointment({ appointment: { ...newAppointment.appointment, EndTime: new Date(args?.value) } }) }}>

                        </DateTimePickerComponent>

                    </td>

                </tr>


                {(newAppointment.appointment.Type == 'Rowing') && <>

                    <tr>

                        <td className='e-textlabel'>Boatclass</td>

                        <td>

                            <DropDownListComponent id='Boatclass' dataSource={boatList.map(({ boatClass }: any) => boatClass)} className='e-field'

                                placeholder='Choose boatclass' onChange={(args: any) => setNewAppointment({ appointment: { ...newAppointment.appointment, Boatclass: args?.value } })} data-name='Boatclass' value={newAppointment.appointment.Boatclass}>

                            </DropDownListComponent>

                        </td>

                    </tr>

                    <tr>

                        <td className='e-textlabel'>Boatname</td>

                        <td>

                            <DropDownListComponent id='Boatname' dataSource={newAppointment.appointment.Boatclass ? boatList.map(({ name, boatClass }: any) => boatClass == newAppointment.appointment.Boatclass ? name : null).filter((name: string) => name != null) : boatList.map(({ name }: any) => name)} className='e-field'

                                placeholder='Choose boatname' onChange={(args: any) => { setNewAppointment({ appointment: { ...newAppointment.appointment, Boatname: args?.value } }); if (!(newAppointment.appointment.Boatclass)) { console.log(newAppointment.appointment.Boatclass); setNewAppointment({ appointment: { ...newAppointment.appointment, Boatclass: boatList.find((e: any) => e.name === args?.value).boatClass } }) } }} data-name='Boatname' value={newAppointment.appointment.Boatname}>

                            </DropDownListComponent>

                        </td>

                    </tr>

                </>

                }

                <tr>

                    <td className='e-textlabel'>Notes</td>

                    <td>

                        <textarea id='Notes' name='Notes' rows={4} cols={50} className='e-field'></textarea>

                    </td>

                </tr>

            </tbody>

        </table >

    )

}



Attachment: simplescreenrecorder20211206_14.33.59_42d7b841.zip


GA Gabriel December 7, 2021 11:05 AM UTC

I solved the issue, it looks i made a mistake when trying to refill the data in the object, in the improved code i reset and refill the object without the create event listener, instead I just use a useEffekt hook with the component props in the dep. array.

Unfortunately i still dont know exactly what caused the error.



VD Vinitha Devi Murugan Syncfusion Team December 7, 2021 12:45 PM UTC

Hi Gabrial, 
 
Thanks for your update. 
 
We are happy that your reported issue has been resolved at your end. 

Please get back to us if you need any further assistance. 
 
Regards, 
Vinitha 



GA Gabriel December 10, 2021 02:13 PM UTC

It seems I have used various Components of the Library wrong or not like they were supposed to. I was able to do a lot fo code refactoring but nevertheless i feel like there could be done more.

I searched a bit but couldnt find a List with all the propertier and functions of the Scheduler Class for example and the documentation in the TS file is not really detailed either. For example: the explanation for 'getAnnouncementString' is just 'Method to generate the announcement string', it may be good to also have a quick explanation what exactly an announcement String is and things like that.

Maybe there is such a chapter in the API Docs and I am just too blind to find them, but although i like the Components you provide I get the impression that the Docs lack short and informative explanations.



VD Vinitha Devi Murugan Syncfusion Team December 13, 2021 11:56 AM UTC

Hi Gabriel, 
 
Thanks for your update. 
 
We suggest you to refer our API document to know more about Scheduler properties, events and public methods. 
 
 
Also, let you know that getAnnouncementString is private method. 
 
Regards, 
Vinitha 


Loader.
Up arrow icon