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

Make compatible with componentDidCatch #8

Open
heygrady opened this issue Apr 13, 2018 · 3 comments
Open

Make compatible with componentDidCatch #8

heygrady opened this issue Apr 13, 2018 · 3 comments

Comments

@heygrady
Copy link

heygrady commented Apr 13, 2018

It should be possible to see that a component has a componentDidCatch method. It would be nice if react-guard could optionally only catch errors at those error boundaries.

The issue is that we want/need to use the client-side error boundary on the client. The official solution allows us to define precisely how the errors are shown. But with react-guard on the server-side, we lose that control.

For example, imagine that the SVG icon in a submit button is throwing an error. On the client I can catch that at the form level and give the user a really nice message that replaces the whole form. This is a great user experience.

By contrast, react-guard would replace only that icon with a generic message. This might lead to a poor user experience.

Forgive me if I am missing something about how react-guard works.

@havenchyk
Copy link
Contributor

@heygrady basically react-guard was a solution before componentDidCatch was introduced.
react-guard just patches render method, surrounds it with try/catch and renders some generic message. componentDidCatch is more convenient and modern way to catch your exceptions from "children", on the other hand, react-guard just cares about exceptions in current component, not in children.

I hope I answered your question

@heygrady
Copy link
Author

heygrady commented Apr 16, 2018

I guess what makes react-guard interesting now is that componentDidCatch does not work on the server but react-guard does.

I need to test this out myself but I was wondering if it would be possible to use the basic underpinnings of react-guard to enable a componentDidCatch (of a approximation of it) on the server. I have a need for error boundaries in my app but it's not great that my server-side-render would render a white screen while the client would be able to recover gracefully.

@havenchyk
Copy link
Contributor

@heygrady https://twitter.com/acdlite/status/986029152405827584 I guess it's better to push react team instead :)

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

No branches or pull requests

2 participants