将TS与Material UI和样式化的组件一起使用

时间:2020-07-01 17:33:17

标签: typescript material-ui styled-components

我在checked抛出以下错误的情况下遇到了这个问题:

`No overload matches this call.
  Overload 1 of 2, '(props: CheckboxProps, context?: any): ReactElement<any, any> | Component<CheckboxProps, any, any> | null', gave the following error.
    Type 'Boolean' is not assignable to type 'boolean | undefined'.
      Type 'Boolean' is not assignable to type 'true'.
  Overload 2 of 2, '(props: PropsWithChildren<CheckboxProps>, context?: any): ReactElement<any, any> | Component<CheckboxProps, any, any> | null', gave the following error.
    Type 'Boolean' is not assignable to type 'boolean | undefined'.
      Type 'Boolean' is not assignable to type 'true'.`
<CheckboxDiv>
        <Checkbox
          onChange={() => dispatch(switchCompleted())}
          checked={status.showCompleted}
          style={{
            color: "#262626",
          }}
          classes={{ root: "custom-checkbox-root" }}
        />
 </CheckboxDiv>

,我不知道它是否会更改某些内容,但是我还定义了index.html文件上的复选框的大小。看起来像这样:

<style>
      .custom-checkbox-root .MuiSvgIcon-root {
        width: 2.1rem;
        height: 2.1rem;
      }
</style>

0 个答案:

没有答案