[英]How can i use '@devexpress/dx-react-scheduler' in ts? It cause Typescript error
I want to use '@devexpress/dx-react-scheduler' library.我想使用“@devexpress/dx-react-scheduler”库。
But it cause Typescript error like under.但它会导致 Typescript 错误,如下所示。
Type '{ children: Element[];类型'{孩子:元素[]; data: AppointmentModel[];数据:约会模型[]; }' is not assignable to type 'IntrinsicAttributes & SchedulerProps'. }' 不可分配给类型 'IntrinsicAttributes & SchedulerProps'。 Property 'children' does not exist on type 'IntrinsicAttributes & SchedulerProps'. “IntrinsicAttributes & SchedulerProps”类型上不存在属性“children”。
I made it the same as in the official documentation ( https://devexpress.github.io/devextreme-reactive/react/scheduler/docs/guides/typescript/ ), but the following error also occurs in the official documentation.我把它和官方文档中的一样( https://devexpress.github.io/devextreme-reactive/react/scheduler/docs/guides/typescript/ ),但是官方文档中也出现了以下错误。
The difference is, the official documentation only shows a warning ( https://codesandbox.io/s/fcj6pm ),不同的是,官方文档只显示了一个警告( https://codesandbox.io/s/fcj6pm ),
import * as React from 'react';
import Paper from '@mui/material/Paper';
import { AppointmentModel, ViewState, SchedulerDateTime } from '@devexpress/dx-react-scheduler';
import {
Scheduler, DayView, Appointments, Resources,
} from '@devexpress/dx-react-scheduler-material-ui';
const Demo = () => {
const [currentDate, setCurrentDate] = React.useState<SchedulerDateTime>('2018-10-31');
return (
<Paper>
<Scheduler
data={appointments}
>
<ViewState
currentDate={currentDate}
onCurrentDateChange={setCurrentDate}
/>
<DayView
startDayHour={7}
endDayHour={12}
/>
<Appointments />
<Resources
data={resources}
/>
</Scheduler>
</Paper>
);
};
export default Demo;
but I get an error(not just a warning) and the screen doesn't appear.但我得到一个错误(不仅仅是一个警告)并且屏幕没有出现。
What should I do..?我应该怎么办..?
Sorry for my late answer.对不起我迟到的答案。 It seems you have to use the component from "@devexpress/dx-react-scheduler".看来您必须使用“@devexpress/dx-react-scheduler”中的组件。 And then set the requiered props.然后设置所需的道具。
like this: (sudo code).像这样:(须藤代码)。 rootComponent returns the from "@devexpress/dx-react-scheduler-material-ui" rootComponent 从“@devexpress/dx-react-scheduler-material-ui”返回
import { Scheduler as MuiSchedular, DayView, Appointments, Resources, } from "@devexpress/dx-react-scheduler-material-ui"; import { AppointmentModel, Scheduler, ViewState, } from "@devexpress/dx-react-scheduler"; export const Calendar = () => { const rootComponent = (props: Scheduler.RootProps) => { return <MuiSchedular.Root {...props} /> }; return ( <Paper> <Scheduler height={"auto"} firstDayOfWeek={1} rootComponent={rootComponent} data={appointments?? []} locale={"da-DK"} > <ViewState currentDate={currentDate} onCurrentDateChange={setCurrentDate} /> <DayView startDayHour={7} endDayHour={12} /> <Appointments /> <Resources data={resources} /> </Scheduler> </Paper> ); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.