TS2322: Type '{ options: { id: number; name: string; }[]; color: string; label: string; defaultValue: number; value: number; handleChange: (e: SelectChangeEvent<unknown>) => void; }' is not assignable to type 'IntrinsicAttributes & CustomSelectBoxProps'.
Property 'color' does not exist on type 'IntrinsicAttributes & CustomSelectBoxProps'.
89 | <CustomSelectBox
90 | options={prefixSuffixContent}
> 91 | color="secondary"
| ^^^^^
92 | label="Select Format"
93 | defaultValue={IS_NUMERIC}
94 | value={prefixSuffixValue}
这在生产构建中出现了。在本地构建中它是好的。
这是我自定义的扩展属性类型:
import { InputBaseProps, SelectChangeEvent, SelectProps } from "@mui/material";
export type OptionsType = {
id: string | number;
name: string;
};
export interface CustomSelectBoxProps extends SelectProps {
/**
* The variant to use.
* @default 'outlined'
*/
variant?: "standard" | "outlined" | "filled";
/**
* The size of the component.
*/
size?: InputBaseProps["size"];
/**
* See [OutlinedInput#label](/material-ui/api/outlined-input/#props)
*/
label?: React.ReactNode;
register?: object | any;
fieldDisable?: InputBaseProps["disabled"];
defaultValue?: InputBaseProps["defaultValue"];
value?: InputBaseProps["value"];
handleBlur?: React.FocusEventHandler<any> | null;
handleChange?: ((event: SelectChangeEvent<unknown>, child: React.ReactNode) => void) | null;
options: any[];
customClass?: string;
inputLabelSize?: "small" | "normal";
disableItems?: any[];
}
<CustomSelectBox
options={prefixSuffixContent}
color="secondary"
register={field}
label="Select Format"
/>
2条答案
按热度按时间u7up0aaq1#
你使用的是哪个版本的Material UI?
你能在Codesandbox或者一个我们可以克隆的仓库中提供一个复制品吗?
vuv7lop32#
@michaldudak https://codesandbox.io/s/customselect-forked-k8lnvj this is my code. but error occurred only production build
and I'm using mui version 5.8.0
https://codesandbox.io/embed/customselect-forked-k8lnvj?fontsize=14&hidenavigation=1&theme=dark