1

Could someone please show me how to implement ComponentDidCatch in SPFx. I did it successfully in ReactJs like this: Throwing an Error :

throw new Error('I crashed!'); 

and it would get caught here:

componentDidCatch(error, errorInfo) {
      // Catch errors in any components below and re-render with error message
      this.setState({
        error: error,
        errorInfo: errorInfo
      })
      // You can also log error messages to an error reporting service here
    } 

However, when I tried to do the same for SPFx , I would get the below error in the browser console, while throwing the error:

Uncaught (in promise) Error: I crashed

Is there a way to catch this error in SPFx?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.