Skip to content

error boundaries #257

Description

@jantimon

does/will fre support error boundaries?

Activity

  1. yisar commented on Apr 19, 2021

    @yisar
    Member

    Fre does not support error boundaries yet, but there are plans to support them in the future, because ErrorBoundary is similar to Suspense, and takes advantage of the fallback feature of the fiber linked list.

  2. yisar commented on Apr 19, 2021

    @yisar
    Member

    @jantimon hi, I am back. According to your issue, I implement this in fre, but it's worth noting that it's different from the API of react16.

    import { ErrorBoundary } from 'fre'
    
    function errorFn(error){
      console.error(error)
      return <div>hello</div>
    }
    
    function App() {
      return <ErrorBoundary fallback={errorFn}>
        <A/>
      </ErrorBoundary>
    }
    
    function A(){
      throw 111
    }

    Fre's ErrorBoundary is more like Suspense, it has a fallback props, which takes advantage of the fallback feature of linked list

    https://github.com/preactjs/preact/blob/master/hooks/src/index.js#L271

    I also see that preact has a hooks API, but I don't think it's appropriate. Although it can catch errors, it doesn't conform to the semantics of fallback and boundary.

    Which do you think is better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions