Skip to content

Conversation

@henryqdineen
Copy link
Contributor

@henryqdineen henryqdineen commented Nov 26, 2025

This PR adds an allowErrorBoundary option to replace the allowComponentDidCatch option. This new option will allow both componentDidCatch and static getDerivedStateFromError methods could be present in an error boundary. Thanks!

@tatethurston
Copy link
Owner

tatethurston commented Nov 27, 2025

Thanks for the PR @henryqdineen. Agreed on allowErrorBoundary (default true) -- I'm comfortable introducing a breaking change and publishing v5 if you're up for making that change.

@tatethurston
Copy link
Owner

tatethurston commented Nov 27, 2025

#CHANGELOG.md

## v5.0.0

- `allowComponentDidCatch` has been replaced with `allowErrorBoundary`. Like `allowComponentDidCatch`,  `allowErrorBoundary` defaults to true, but `allowErrorBoundary` allows class components that use `componentDidCatch` and/or `getDerivedStateFromError`. No change is required if you're using the defaults for this lint rule. If you've disabled `allowComponentDidCatch`, you'll need to make the following change:

```diff
- "react-prefer-function-component": [true, { "allowComponentDidCatch": false }]
+ "react-prefer-function-component": [true, { "allowErrorBoundary": false }]

@henryqdineen henryqdineen force-pushed the hqd-get-derived-state-from-error branch from b231381 to b0f08c4 Compare November 28, 2025 04:32
@henryqdineen henryqdineen changed the title add allowGetDerivedStateFromError option add allowErrorBoundary option Nov 28, 2025
@henryqdineen
Copy link
Contributor Author

henryqdineen commented Nov 28, 2025

Thanks @tatethurston! I just pushed a commit to implement allowErrorBoundary and updated PR subject/body.

@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.05%. Comparing base (c9d5d79) to head (b0f08c4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...n-component/src/prefer-function-component/index.ts 90.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main      #29      +/-   ##
===========================================
- Coverage   100.00%   99.05%   -0.95%     
===========================================
  Files            3        3              
  Lines          103      106       +3     
  Branches        18       21       +3     
===========================================
+ Hits           103      105       +2     
- Misses           0        1       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner

@tatethurston tatethurston left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

@tatethurston tatethurston merged commit fb0ca63 into tatethurston:main Nov 28, 2025
3 of 5 checks passed
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.

2 participants