简体   繁体   English

如何在 ts 中使用“@devexpress/dx-react-scheduler”? 它会导致 Typescript 错误

[英]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.

相关问题 如何在 typescript 中使用 package xpath-ts + xmldom? - How can I use package xpath-ts + xmldom in typescript? 如何解决打字稿/反应错误 TS7053? - How do I solve typescript/react error TS7053? 如何在 TypeScript 中使用 no-typescript React 组件? - How can I use no-typescript React component in TypeScript? 如何在 React 打字稿中使用镭(错误:与类型“CSSProperties”没有共同的属性。TS2559)? - How to use radium in React typescript (Error: has no properties in common with type 'CSSProperties'. TS2559)? 如何解决打字稿中与错误相关的错误:TS2705 - How can I resolve the error related error:TS2705 in typescript 我可以在 io-ts 中使用 TypeScript 类型吗 - Can I use type of TypeScript in io-ts 在Typescript中,如何使用另一个TS文件中定义的函数而不将它们放在模块中? - In Typescript, how can I use functions defined in another TS file without puting them in a module? 我可以为 typescript 上的错误 ts(7053) 提供帮助吗? - Can I have help for my error ts(7053) on typescript? 我该如何解决“错误:TypeScript 编译中缺少 \\src\\main.ts”。 - How can i solve "Error: \src\main.ts is missing from the TypeScript compilation." ts2339错误:如何在vuejs项目中使用typescript mixin? - ts2339 error: how to use typescript mixin in vuejs project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM