-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[ErrorBoundary] New ErrorBoundary Component #19945
Comments
@dimitropoulos Thanks for opening this issue! :) If I understand the motivation correctly, the component is about improving the user experience in production? It sounds great. On the execution of the idea side of things. A few thoughts, at first sight, but happy to be proven otherwise:
|
Could you please say a little more as to why? In the above implementation setting
I share that curiosity. What I meant is that this is (from a DOM structure perspective) relatively simple component and I think that tying it to the Alert component will only complicate matters. If you feel strongly, by all means, I am happy to give using Alert a try! :)
I don't have a lot of background on what you're talking about: could you please point me in the right direction?
yep! this could be one of the big innovations by material-ui's implementation, and, after all, it'd only be like 4 lines of code!
hmmmmm.... yeah... I see what you mean. I see it both ways (and, I think you can too). Sometimes when you're developing you want to just forge ahead past a few (temporary) errors. Other times, though, you really really want to see the app exactly as the users will see it (but without losing all the other benefits of things that exist in dev mode like better hot reloading and build times, etc.). I can agree that we can start out with a debug prop (I'm assuming that's what you meant by "
For sure, yeah,
Good call. I lifted the terminology from the Carbon. This popular error boundary component uses
See above, but I've added it to the description |
As a end-user (not as a developer), I don't want to see the stack trace of an error, it's noise.
We could accept a React component. The usage of No objection with the other comments. |
Ok. I see what you mean. I think it depends on the audience but you've brought me to reconsider my position and upon reconsideration I now strongly agree with you. Most audiences (end users) will see a stack trace as an active act of aggression, hahaha. The default should be to hide the componetStack.
Just to put this in front of us while we're talking: type ReactText = string | number;
type ReactChild = ReactElement | ReactText;
interface ReactNodeArray extends Array<ReactNode> {}
type ReactFragment = {} | ReactNodeArray;
type ReactNode = ReactChild | ReactFragment | ReactPortal | boolean | null | undefined; I picked ReactNode rather than |
Let me know, though, if you think you have enough interest for me to start on a proof of concept. I'm trying to plan out my next few nights/weekends (which is when I could work on this) and I'd love to pencil this in if it's of interest to you! |
@dimitropoulos From my perspective, using I personally think that it's worth exploring, I don't know about what the rest of the team think :). I think that it would be ideal to identify exactly how it will be used in practice. |
This ticket is to track ideas/rationale for material-ui including an ErrorBoundary component.
I would like to contribute this component to material-ui, as described below.
Summary 💡
ErrorBoundaries are a React 16+ specific feature that uses the componentDidCatch API for handling uncaught errors without unmounting the whole React component tree.
This ticket exists to request feedback and ideas for a material-ui-provided ErrorBoundary component.
Examples 🌈
The react-ui-roundup tracks ErrorBoundaries, and it appears that there are just 3 implementations:
For convenience, I've linked to the actual code for these three here:
title
anddescription
prop (both strings), but not for passing in a custom fallback component, which is a bummer.So basically, I'm suggesting a mashup of the above 3, the looks of Eui, the simple string api of AntD, the flexible fallback (if you really need or want it), and two more little additions (they're related).
I have done a few of these ErrorBoundary components for various projects in the past and one thing I ALWAYS end up needing is a little section at the bottom of the callstack where I can tell the user something like:
Or (better) sometimes it's appropriate to have a button that the user can click to contact support that will then open up something like Intercom, will start an email with some useful information pre-populated, or will send an error report dialog with something like getSentry.
Speaking of which, mature codebases will often be tracking errors of this sort with something like getSentry, and the
onCatch
prop exists as a simple callback that will allow the user to trigger some analytics (or other change) if an error state is to occur.I propose the following API:
As far as styling goes, I think Elastic's looks best. Perhaps we can just play around with material-ui internals and quickly find something suitable that works in both light and dark themes.
Motivation 🔦
this was mentioned by @oliviertassinari #19744 (comment) in a comment about improving user experience.
The text was updated successfully, but these errors were encountered: