question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Types for ErrorBoundary?

See original GitHub issue
  • react-error-boundary version: 2.3.1
  • node version:14.4
  • npm version: 6.4.7

Relevant code or config

            <ErrorBoundary FallbackComponent={errorFallback}>
            </ErrorBoundary>

What you did: Wrapped a section of JSX with the ErrorBoundary component

What happened:

Visual Studio Code complains with a red squiglly line that “no overload matches this call”

Problem description:

I am thinking that the reason that the JSX for ErrorBoundary is causing a warning is that this is inside of a .tsx component and I need type information for the props for ErrorBoundary.

Suggested solution:

Documentation on how to use ErrorBoundary in a TypeScript component.

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

13reactions
marcosvega91commented, Aug 1, 2020

If you add type to your props will work

const errorFallback = ({ error }: FallbackProps) => {
  return (
    <div role="alert">
      <p>Something went wrong:</p>
      <pre style={{ color: "red" }}>{error?.message}</pre>
    </div>
  );
};
3reactions
KevinBurtoncommented, Aug 2, 2020

Thank you. That is what I was looking for.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Boundaries - React TypeScript Cheatsheets
React-error-boundary - is a lightweight package ready to use for this scenario with TS support built-in. This approach also lets you avoid class...
Read more >
Error Boundaries - React
A class component becomes an error boundary if it defines either (or both) of the lifecycle methods static getDerivedStateFromError() or componentDidCatch() .
Read more >
How to properly type a React ErrorBoundary class component ...
This question is about the types for this ErrorBoundary class component. I'm breaking it into parts to make it easier.
Read more >
react-error-boundary - npm
This component provides a simple and reusable wrapper that you can use to wrap around your components. Any rendering errors in your components ......
Read more >
react/error-boundaries.md at main · typescript-cheatsheets/react
React-error-boundary - is a lightweight package ready to use for this scenario with TS support built-in. This approach also lets you avoid class...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found