[Table] TablePaginationActions onChange prop is not overridable
See original GitHub issueBasically 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/modify on onChangePage
prop 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 event type.
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>'.
Q: why event
object is a major paramater and needs to be passed all over? my codebase doesn’t depend or need it.
Tech | Version |
---|---|
Node | 12.18.0 |
React | 16.11.0 |
Typescript | 3.8.3 |
@material-ui/core | 4.11.0 |
@material-ui/lab | 4.0.0-alpha.56 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Material UI material-table TablePagination issue. (React)
Material-UI: The key caption provided to the classes prop is not implemented in ForwardRef(TablePagination). You can only override one of the ...
Read more >TablePagination deprecated props in 4.x.x introduced ...
TablePagination no longer passes the custom ActionsComponent an onChangePage prop, causing the app to crash. Expected Behavior.
Read more >TablePagination API - Material UI
The name MuiTablePagination can be used when providing default props or style overrides in the theme. Props. Props of the TableCell component are...
Read more >material-table
Actions. You can add one or multiple row based actions easily ; Component Overriding. You can override any component of material-table ; Custom...
Read more >API - React Select
Even when commonProps are not listed in the prop types below, a custom component ... Override the built-in logic to detect whether an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@MahmoudZakariaMT v5 is documented at http://next.material-ui.com/. The
onChangePage
is the v4 name for the prop, the name in v5 isonPageChange
.@MahmoudZakariaMT Also mind that we only provide support on v5.