Skip to content
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

feat: add renderError property #175

Merged
merged 2 commits into from
Jun 20, 2023
Merged

feat: add renderError property #175

merged 2 commits into from
Jun 20, 2023

Conversation

EgorKluch
Copy link
Contributor

  • Add renderErrorView prop for custom render and handle errors
  • Reset error on data prop change

<ErrorBoundary onError={props.onError}>
<ErrorBoundary
onError={props.onError}
resetError={handleResetError}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's seems, resetError bad prop name - it's callback or fallback, I don't know...

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

resetError: () => void;
};

export type ErrorBoundaryRenderErrorView = (
Copy link
Contributor Author

@EgorKluch EgorKluch Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to add more readable type, but it's forbidden.

export declare namespace ErrorBoundary {
    export type RenderErrorViewOpts = {
        message: string;
        error: ChartKitError | Error;
        resetError: () => void;
    };

    export type RenderErrorView = (opts: RenderErrorViewOpts) => React.ReactNode
}

// ...

renderErrorView?: ErrorBoundary.RenderErrorView;

Why namespaces are forbidden?

@EgorKluch EgorKluch force-pushed the add-error-handling branch 2 times, most recently from 3b04066 to 964b3fe Compare June 20, 2023 08:07
@EgorKluch EgorKluch force-pushed the add-error-handling branch 2 times, most recently from b836554 to cf4e49b Compare June 20, 2023 08:12
@EgorKluch EgorKluch force-pushed the add-error-handling branch from cf4e49b to fe4af3f Compare June 20, 2023 10:29
@EgorKluch EgorKluch changed the title Add error handling feat: add renderError property Jun 20, 2023
@EgorKluch EgorKluch merged commit 84c03a9 into main Jun 20, 2023
@EgorKluch EgorKluch deleted the add-error-handling branch June 20, 2023 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants