We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Properties don't use defaults when passed in undefined or null

Putting this here as reference, maybe it'll get fixed, but there is a workaround. but took me ages to work this out.


When you have the following and the group and timescale properties are undefined, the scheduler causes a js error and breaks react. It should be using the defaults as per the scheduler api doco.


use case is that I want to pass these in from other components (or not). I've had to set them to the defaults if they are undefined from the parent component.


const myGenericScheduler = ({group, timeScale}) => {

   return <ScheduleComponent group={group} timeScale={timeScale} />

}



3 Replies

RM Ruksar Moosa Sait Syncfusion Team October 13, 2022 09:39 AM UTC

Hi Paul,


We have checked on your query and suggest you set the default value for the timeScale if the timeScale value is undefined like the below code to overcome your reported issue.


const timeScale = undefined;


<ScheduleComponent
width='auto'
height='550px'
selectedDate={new Date(2021010)}
workDays={workDays}
eventSettings={dataSource:data }}
currentView='Week'
timeScale={timeScale ? timeScale : { enable:trueinterval:60slotCount:2 }}>

  </ScheduleComponent>


Sample: https://stackblitz.com/edit/react-4bwojz?file=index.js


Kindly try the above sample and let us know if this meets your requirement.


Regards,

Ruksar Moosa Sait



PA Paul October 13, 2022 11:14 PM UTC

Hi Ruksar,


Yes I realise we can pass the defaults, that is what we're doing. I guess my post was that, that isn't really the point. It shouldn't break when passing undefined. It's a pretty natural react pattern to set it up the way I am where variables may be passed as undefined, I don't think your components should be breaking when passed undefined variables.


Regards

Paul



RV Ravikumar Venkatesan Syncfusion Team October 14, 2022 07:10 AM UTC

Hi Paul,


We have validated your reported problem “It shouldn't break when passing undefined” at our end. But, we are unable to reproduce the problem at our end. We have prepared a sample for your reference.


Sample: https://stackblitz.com/edit/ej2-react-schedule-timescale-sample?file=timescale.js


Kindly try our shared sample and if you still facing the same problem share the below details it will help us to provide the solution for your problem earlier.

  • Share an issue reproducing the video demo.
  • Reproduce the issue in our shared sample or
  • Share a simple issue reproducing sample if possible.


Regards,

Ravikumar Venkatesan


Loader.
Live Chat Icon For mobile
Up arrow icon