You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched this repository's issues and believe that this is not a duplicate.
I'm using ...
React Grid
React Chart
React Scheduler
Current Behaviour
I'm trying to build a custom weekly recurrence selector component (in TypeScript) and I'm having some trouble with using the AppointmentForm.WeeklyRecurrenceSelectorProps interface
onFieldChange is undefined when I try to use it in my code, even though the interface in the scheduler repo is:
/** Properties passed to a component that renders a weekly recurrence selector on the appointment form. */
interface WeeklyRecurrenceSelectorProps {
/** A function that formats dates based on the locale. */
formatDate: FormatterFn;
/** A number between 0 (Sunday) and 6 (Saturday) that specifies the first day of the week. */
firstDayOfWeek: number;
/** Specifies the recurrence rule. */
rRule: string;
/** Specifies whether the weekly recurrence selector is read-only. */
readOnly: boolean;
/** Handles appointment field value changes. */
onFieldChange: (nextFieldValue: {
[fieldName: string]: any;
}) => void;
}
Expected Behaviour
According to the documentation, AppointmentForm.WeeklySelectorProps should have a property called onValueChange, not onFieldChange, though the type of onValueChange is the same as other onFieldChange fields, so I'm wondering if this was just a mistyped field.
Steps to Reproduce
Create a custom stateless component in TypeScript that takes in an argument {...props} of type AppointmentForm.WeeklyRecurrenceSelectorProps
Use the onFieldChange property from props in any way you like
onFieldChange will be undefined, and if you debug you'll see onValueChange defined in props instead
If anyone is facing the same issue, my workaround is to define my own WeeklyRecurrenceSelectorProps interface and then typecast AppointmentForm.WeeklyRecurrenceSelectorProps to that interface:
interface CustomWeeklyRecurrenceSelectorProps {
formatDate: FormatterFn;
firstDayOfWeek: number;
rRule: string;
readOnly: boolean;
onValueChange: (nextFieldValue: Record<string, any>) => void;
}
export default const WeeklyRecurrenceSelector: React.FC<AppointmentForm.WeeklyRecurrenceSelectorProps> = ({
...props
}) => {
const newProps = (props as unknown) as CustomWeeklyRecurrenceSelectorProps;
const { onValueChange } = newProps; // Can now use onValueChange in selector buttons
...
}
I'm using ...
Current Behaviour
I'm trying to build a custom weekly recurrence selector component (in TypeScript) and I'm having some trouble with using the
AppointmentForm.WeeklyRecurrenceSelectorProps
interfaceonFieldChange
is undefined when I try to use it in my code, even though the interface in the scheduler repo is:Expected Behaviour
AppointmentForm.WeeklySelectorProps
should have a property calledonValueChange
, notonFieldChange
, though the type ofonValueChange
is the same as otheronFieldChange
fields, so I'm wondering if this was just a mistyped field.Steps to Reproduce
{...props}
of typeAppointmentForm.WeeklyRecurrenceSelectorProps
onFieldChange
property fromprops
in any way you likeonFieldChange
will be undefined, and if you debug you'll seeonValueChange
defined inprops
insteadLink to the example that reproduces the issue: https://codesandbox.io/s/devextreme-react-scheduler-for-material-ui-forked-cq56i?file=/index.js
Environment
The text was updated successfully, but these errors were encountered: