Skip to content

Conversation

@lobsterkatie
Copy link
Member

We already know error exists because of the if (error) check.

Fixes #2892.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 10, 2020

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 17.69 KB (0%)
@sentry/browser - Webpack 18.51 KB (0%)
@sentry/react - Webpack 18.51 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 23.47 KB (+0.01% 🔺)

@twavv
Copy link
Contributor

twavv commented Sep 10, 2020

Similarly, componentStack will never be non-null, though I think that would fail type-checking right now.

A good solution might just to be to store all of the information about the error in one single state variable?

interface State {
  errorInfo: null | {
    error: Error
    componentStack: string
    ...
  }
}

// instead of
interface State {
  error: Error | null
  componentStack: string | null
}

Copy link
Contributor

@kamilogorek kamilogorek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original issue fix looks good, you can approach the issue from @travigd either here or separate PR.

@lobsterkatie lobsterkatie force-pushed the kmclb-react-error-always-exists-for-fallback branch from a95248e to 9ca1519 Compare September 14, 2020 21:04
@lobsterkatie
Copy link
Member Author

@travigd - That's not a bad idea in the long run, but for the moment we're going to hold off, just to get this in without further complication.

If you're interested and can do it in such a way that it won't be a breaking change for anyone using it now, we welcome PRs! 🙂

@lobsterkatie lobsterkatie merged commit 45761bc into master Sep 14, 2020
@lobsterkatie lobsterkatie deleted the kmclb-react-error-always-exists-for-fallback branch September 14, 2020 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In React ErrorBoundary, fallback function should not have nullable error type

4 participants