Skip to content

Errors handing for effect callbacks  #308

Closed
@mpeyper

Description

@mpeyper

Originally raised in #305, errors throw in useEffect (and useLayoutEffect) callbacks are not being captured in result.error like other rendering and async errors.

A quick test showed that using an error boundary would catch the errors in the effects. We used to have a an error boundary for error handling, but after issues found in #50 and #74, it was removed.

I'm proposing we reintroduce the error back into the mix.

As an alternative approach, I think it might also worth exploring an alternative where we no longer try to catch errors and just have renderHook, rerender and all the async utils just throw them. This would be a breaking change, but I suspect it will actually be a more ergonomic and idiomatic testing experience. I haven't put too much thought into this approach yet, so there might be some issues with it.

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