-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typing of custom component to render in GridActionsCellItem #4654
Comments
Was hitting the same issue after upgrading mui packages in Toolpad. Did a quick code review and I believe this issue has the same root cause as mui/material-ui#32392. |
@Janpot is right. The diff --git a/packages/grid/x-data-grid/src/components/cell/GridActionsCellItem.tsx b/packages/grid/x-data-grid/src/components/cell/GridActionsCellItem.tsx
index a54b786da..1e6096c64 100644
--- a/packages/grid/x-data-grid/src/components/cell/GridActionsCellItem.tsx
+++ b/packages/grid/x-data-grid/src/components/cell/GridActionsCellItem.tsx
@@ -7,6 +7,7 @@ import ListItemIcon from '@mui/material/ListItemIcon';
export type GridActionsCellItemProps = {
label: string;
icon?: React.ReactElement;
+ component?: React.ElementType;
} & (
| ({ showInMenu?: false; icon: React.ReactElement } & IconButtonProps)
| ({ showInMenu: true } & MenuItemProps) |
hi! has this been added ? |
Still not fixed. A nasty workaround for now: import {GridActionsCellItem, GridActionsCellItemProps} from "@mui/x-data-grid";
import React, {RefAttributes} from "react";
import {Link as RouterLink} from "react-router-dom";
type GridLinkActionProps = {to: string} & GridActionsCellItemProps & RefAttributes<HTMLButtonElement>;
const GridLinkAction = ({to, ...props}: GridLinkActionProps) => {
return (<RouterLink to={to}>
<GridActionsCellItem {...props} />
</RouterLink>);
};
export default GridLinkAction; |
Or, one more workaround // This is a workaround due to known issue https://github.com/mui/mui-x/issues/4654
const EditLink = forwardRef<HTMLAnchorElement>((props, ref) => {
return <RouterLink ref={ref} {...props} to={generatePath(ROUTES.edit, {id})} />;
});
EditLink.displayName = 'EditLink';
return (
<GridActionsCellItem
{...props}
component={EditLink}
/>
); |
Duplicates
Latest version
Current behavior 😯
Why using version
5.6.1
ofmui-x/data-grid
we were using thecomponent
prop of the underlyingButtonBase
component in order to integrate withreact-router
as follows:While Updating to versions older then
5.7.0
we are experiencing typing error stating thatGridActionsCellItem
doesn't have this prop enymore.I followed the history of this component here but it seems that nothin relevant has been changed.
I found this commit containing bundling changes and did manged to find out that the difference between the latest version and the last version that has this feature working is type called
GridActionsCellItem
that has been added to the typing file in addition toGridActionsCellItemProps
.The text was updated successfully, but these errors were encountered: