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

ErrorBoundary useless with React 16.4 handling of getDerivedStateFromProps #4708

Closed
morgs32 opened this issue Jul 1, 2018 · 3 comments · Fixed by #4639
Closed

ErrorBoundary useless with React 16.4 handling of getDerivedStateFromProps #4708

morgs32 opened this issue Jul 1, 2018 · 3 comments · Fixed by #4639

Comments

@morgs32
Copy link

morgs32 commented Jul 1, 2018

Bug report

Describe the bug

With the new handling of getDerivedStateFromProps, the ErrorBoundary's state is constantly reset (error to null) before every render. Therefore it is never able to render the ErrorReporter and instead attempts to rerender the faulty Page/react components.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. https://github.com/morgs32/with-next-routes
  2. yarn && yarn dev
  3. Click on either of the two buttons to go to the about page

Expected behavior

Expect the ErrorBoundary to render next/_error.js with the associated error and stacktrace.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: [e.g. macOS, Windows]
  • Browser
  • React 16.4.1
  • Version of Next.js: 6.1.1

Additional context

If you revert to 16.3.2 this is not an issue. getDerivedStateFromProps does not get called before the re-render, leaving state.error intact.

@timneutkens
Copy link
Member

@timneutkens timneutkens added help wanted good first issue Easy to fix issues, good for newcomers labels Jul 1, 2018
@vitorbal
Copy link
Contributor

@timneutkens I can try to pick this up. What's the desired behavior that the getDerivedStateFromProps of ErrorBoundary is trying to achieve? Is it so the error goes away after a hot-reload?

@timneutkens
Copy link
Member

@vitorbal there's no need to do fix this anymore, I've rewritten most of the logic involving the error overlay in my webpack 4 PR, the development error overlay is now handled by react-error-overlay.

Thank you very much for wanting to help though, very much appreciated, there's quite a few other "good first issue" / "help wanted" issues which we'd love help on 🙏❤️

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants