0

I am trying to implement ErrorBoundary from react-error-boundary like this:

import React from 'react'; 
import { ErrorBoundary } from "react-error-boundary";

function Fallback({ error }) {
  return (
    <div role='alert'>
      <p>Something went wrong:</p>
      <pre style={{ color: 'red' }}>{error.message}</pre>
    </div>
  );
}

const App = () => {
return (
  <ErrorBoundary FallbackComponent={Fallback} 
  onReset={details => {console.log(details);}}>
    <ExapleComponent/>
  </ErrorBoundary>
  )
}

But I get

Binding element 'error' implicitly has an 'any' type.
I tried changing { error } with { error: Error }, but did not work.

1 Answer 1

0

The solution was to change { error } with { error }:{ error: Error }

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.