Skip to content

Report error when error boundary's componentDidCatch do not call setState #5002

@upupming

Description

@upupming

Describe the feature you'd love to see

When using componentDidCatch, users might forget to run this.setState to set a new state. In this case, preact will throw an error at process function and fail to set process._rerenderCount = 0, which will prevent future enqueueRender working properly.

I have created two example cases: Preact, React. In this example, when we click the counter up to 3, it will throw an error, and the parent error boundary will not setState in their componentDidCatch.

For React, it will remind user to call setState properly, see their impl at here:

Image

For Preact, it will sliently break and the page will be not interactivable any more.

So I would suggest we can add an error message on this circumstances. I'd be happy to submit a PR to support this; please let me know if you have any suggestion or concerns.

Additional context (optional)
N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions