Skip to content

There doesn't appear to be a way to completely disable Error Boundaries #1172

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

Closed
jeremym opened this issue Feb 7, 2019 · 2 comments
Closed

Comments

@jeremym
Copy link

jeremym commented Feb 7, 2019

Description

I'd like to use our own implemented react error boundaries that would act the same for dev and prod (well... prod-like testing environments). It doesn't seem to be possible to disable Error Boundaries in when AppContainer.dev.js is used.

Passing in a config object as the 2nd argument to hot() that looks like this: {errorBoundary: false} has no impact.

The above false errorBoundary config prop + using setConfig({ ErrorOverlay: () => null }) results in catching the error in dev and displaying only the react-hot-loader Error emojis:
https://i.imgur.com/iHPYZJA.png

Expected behavior

Setting errorBoundary to false should turn off all error boundary functionality. (I realize that since we don't have multi-level inheritance, that it might require creating another AppContainer.dev.js without the componentDidCatch --- or, wait... does that void return cause other catches in the chain to be able to catch? Maybe another condition simply needs to be added to if (!hotComparisonOpen()).

Actual behavior

Error Boundary always catches and always displays something, regardless of config.

Environment

React Hot Loader version: 4.6.5

Run these commands in the project folder and fill in their results:

  1. yarn -v: 1.12.1 (using yarn)

  2. npm -v: 6.4.1

  3. node -v: 11.0

  4. OS: High Sierra 10.13.6

  5. Browser: Chrome 71.0.3578.98 (Official Build) (64-bit)

Reproducible Demo

You can use this boilerplate and simply put x=y in the render method.
https://github.com/MichalZalecki/react-boilerplate-lite

Using different combinations of:

const hmrOptions = {
  errorBoundary: false,
};
setConfig({ ErrorOverlay: () => null });
export default hot(module, hmrOptions)(App, hmrOptions);  // looking through the source, one of these isn't necessary, but now I don't remember which.  😄 
@theKashey
Copy link
Collaborator

I was quite sure that after that last changes (ie hotComparisonOpen) ErrorBoundaries are working only when for HMR, not when an application is a normal state. Let me play with your example.

@jeremym
Copy link
Author

jeremym commented Feb 7, 2019

@theKashey - when I happened upon that bug, commented, and saw your quick response last week, I was sure it would fix the issue I was having. So, ME TOO! :-)

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