TablePaginationActionsProps is not overridable

Viewed 215

Basically I've this interface from Material-UI docs while implementing CustomTablePaginationAction component Material-UI CustomTablePaginationAction

interface TablePaginationActionsProps {
  count: number;
  page: number;
  rowsPerPage: number;
  onChangePage: (event: React.MouseEvent<HTMLButtonElement>, newPage: number) => void;
}

The thing is if I want to add on this props interface like below

onChangePage: (event: React.MouseEvent<HTMLButtonElement> | React.ChangeEvent<unknown>, newPage: number) => void;

It gets me an error, like I can't modify/override the prop type.

Another question: why event object is a major param and needs to be passed all over? my codebase doesn't depend or need it.

No overload matches this call.
  Overload 1 of 2, '(props: { component: ElementType<any>; } & Pick<TableCellProps, "onError" | "ref" | "abbr" | "slot" | "style" | "title" | "hidden" | "children" | "size" | ... 257 more ... | "variant"> & { ...; } & CommonProps<...> & 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>'.
0 Answers
Related