-
-
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
[data grid] ErrorOverlay not passed with defined input props #6800
Comments
This can be fixed with: diff --git a/packages/grid/x-data-grid/src/components/ErrorBoundary.tsx b/packages/grid/x-data-grid/src/components/ErrorBoundary.tsx
index 35acbb1ad..67cca6bf5 100644
--- a/packages/grid/x-data-grid/src/components/ErrorBoundary.tsx
+++ b/packages/grid/x-data-grid/src/components/ErrorBoundary.tsx
@@ -8,7 +8,6 @@ export interface ErrorBoundaryProps {
render: ({ error }: any) => React.ReactNode;
api: React.MutableRefObject<GridApiCommunity>;
hasError: boolean;
- componentProps?: any[];
children?: React.ReactNode;
}
@@ -38,7 +37,7 @@ export class ErrorBoundary extends React.Component<ErrorBoundaryProps, any> {
render() {
if (this.props.hasError || this.state?.hasError) {
// You can render any custom fallback UI
- return this.props.render(this.props.componentProps || this.state);
+ return this.props.render(this.state);
}
return this.props.children;
diff --git a/packages/grid/x-data-grid/src/components/ErrorOverlay.tsx b/packages/grid/x-data-grid/src/components/ErrorOverlay.tsx
index 7745d3852..9a7715bc9 100644
--- a/packages/grid/x-data-grid/src/components/ErrorOverlay.tsx
+++ b/packages/grid/x-data-grid/src/components/ErrorOverlay.tsx
@@ -5,7 +5,7 @@ import { useGridSelector } from '../hooks/utils/useGridSelector';
import { gridDensityRowHeightSelector } from '../hooks/features/density/densitySelector';
export interface ErrorOverlayProps extends GridOverlayProps {
- message?: string;
+ error?: Error;
hasError: boolean;
errorInfo: any;
}
@@ -13,14 +13,14 @@ export interface ErrorOverlayProps extends GridOverlayProps {
// TODO v6: rename to GridErrorOverlay
export const ErrorOverlay = React.forwardRef<HTMLDivElement, ErrorOverlayProps>(
function ErrorOverlay(props: ErrorOverlayProps, ref) {
- const { message, hasError, errorInfo, ...other } = props;
+ const { error, hasError, errorInfo, ...other } = props;
const apiRef = useGridApiContext();
const defaultLabel = apiRef.current.getLocaleText('errorOverlayDefaultLabel');
const rowHeight = useGridSelector(apiRef, gridDensityRowHeightSelector);
return (
<GridOverlay ref={ref} sx={{ width: '100%', minHeight: 2 * rowHeight }} {...other}>
- {message || defaultLabel}
+ {error?.message || defaultLabel}
</GridOverlay>
);
},
diff --git a/packages/grid/x-data-grid/src/components/base/GridErrorHandler.tsx b/packages/grid/x-data-grid/src/components/base/GridErrorHandler.tsx
index 3334faa01..783e2720a 100644
--- a/packages/grid/x-data-grid/src/components/base/GridErrorHandler.tsx
+++ b/packages/grid/x-data-grid/src/components/base/GridErrorHandler.tsx
@@ -11,18 +11,18 @@ function GridErrorHandler(props: { children: React.ReactNode }) {
const apiRef = useGridApiContext();
const logger = useGridLogger(apiRef, 'GridErrorHandler');
const rootProps = useGridRootProps();
- const error = apiRef.current.state.error;
+ const errorState = apiRef.current.state.error;
return (
<ErrorBoundary
- hasError={error != null}
- componentProps={error}
+ hasError={errorState != null}
api={apiRef}
logger={logger}
render={(errorProps) => (
<GridMainContainer>
<rootProps.components.ErrorOverlay
{...errorProps}
+ {...errorState}
{...rootProps.componentsProps?.errorOverlay}
/>
</GridMainContainer> Do you want to submit a PR? Since Side note: For v6 we plan to remove the default error boundary in #1804. |
@m4theushw I have created PR for this fix. can you please review my PR? Thanks in advance. |
@scott-avery Just an FYI, in v6, for consistency, we renamed |
Thanks for the notice @MBilalShafi |
Update: |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/hopeful-meadow-vdskw6
Steps:
Current behavior 😯
ErrorOverlay
doesn't render withErrorOverlayProps
but state fromErrorBoundary
.Expected behavior 🤔
Redefine
ErrorOverlayProps
or fix the mechanismContext 🔦
No response
Your environment 🌎
latest
Order ID 💳 (optional)
53318
The text was updated successfully, but these errors were encountered: