#material-ui
#материал-пользовательский интерфейс
Вопрос:
В основном я использую этот интерфейс из документов Material-UI при реализации компонента CustomTablePaginationAction Material-UI CustomTablePaginationAction
interface TablePaginationActionsProps {
count: number;
page: number;
rowsPerPage: number;
onChangePage: (event: React.MouseEvent<HTMLButtonElement>, newPage: number) => void;
}
Дело в том, что я хочу добавить в этот интерфейс реквизита, как показано ниже
onChangePage: (event: React.MouseEvent<HTMLButtonElement> | React.ChangeEvent<unknown>, newPage: number) => void;
Это выдает мне ошибку, например, я не могу изменить / переопределить тип реквизита.
Еще один вопрос: почему event
object является основным параметром и должен передаваться повсюду? моя кодовая база не зависит и не нуждается в этом.
No overload matches this call.
Overload 1 of 2, '(props: { component: ElementType<any>; } amp; Pick<TableCellProps, "onError" | "ref" | "abbr" | "slot" | "style" | "title" | "hidden" | "children" | "size" | ... 257 more ... | "variant"> amp; { ...; } amp; CommonProps<...> amp; Pick<...>): Element', gave the following error.
Type '(props: ITablePaginationActionsProps) => JSX.Element' is not assignable to type '"object" | "big" | "small" | "sub" | "sup" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "blockquote" | "caption" | "cite" | "code" | "col" | "colgroup" | "dd" | ... 61 more ... | undefined'.
Type '(props: ITablePaginationActionsProps) => JSX.Element' is not assignable to type 'FunctionComponent<TablePaginationActionsProps>'.
Types of parameters 'props' and 'props' are incompatible.
Type 'PropsWithChildren<TablePaginationActionsProps>' is not assignable to type 'ITablePaginationActionsProps'.
Types of property 'onChangePage' are incompatible.
Type '(event: MouseEvent<HTMLButtonElement, MouseEvent> | null, page: number) => void' is not assignable to type '(event?: MouseEvent<HTMLButtonElement, MouseEvent> | ChangeEvent<unknown> | undefined, currentPage?: number | undefined) => void'.
Types of parameters 'event' and 'event' are incompatible.
Type 'MouseEvent<HTMLButtonElement, MouseEvent> | ChangeEvent<unknown> | undefined' is not assignable to type 'MouseEvent<HTMLButtonElement, MouseEvent> | null'.
Type 'undefined' is not assignable to type 'MouseEvent<HTMLButtonElement, MouseEvent> | null'.
Overload 2 of 2, '(props: DefaultComponentProps<TablePaginationTypeMap<{}, ComponentType<Pick<TableCellProps, "onError" | "ref" | "abbr" | "slot" | "style" | "title" | "hidden" | "children" | "size" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | ... 254 more ... | "variant">>>>): Element', gave the following error.
Type '(props: ITablePaginationActionsProps) => JSX.Element' is not assignable to type '"object" | "big" | "small" | "sub" | "sup" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "blockquote" | "caption" | "cite" | "code" | "col" | "colgroup" | "dd" | ... 61 more ... | undefined'.
Type '(props: ITablePaginationActionsProps) => JSX.Element' is not assignable to type 'FunctionComponent<TablePaginationActionsProps>'.