Skip to content

feat(react): Drop support for React 15 #10115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Upgrading from 7.x to 8.x

## Dropping Support for React 15

Sentry will no longer officially support React 15 in version 8. This means that React 15.x will be removed
from`@sentry/react`'s peer dependencies.

## Removal of deprecated API in `@sentry/nextjs`

The following previously deprecated API has been removed from the `@sentry/nextjs` package:
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"peerDependencies": {
"gatsby": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
"react": "15.x || 16.x || 17.x || 18.x"
"react": "16.x || 17.x || 18.x"
},
"devDependencies": {
"@testing-library/react": "^13.0.0",
Expand Down
20 changes: 10 additions & 10 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To use this SDK, call `Sentry.init(options)` before you mount your React compone

```javascript
import React from 'react';
import ReactDOM from "react-dom";
import ReactDOM from 'react-dom';
import * as Sentry from '@sentry/react';

Sentry.init({
Expand All @@ -39,17 +39,16 @@ ReactDOM.render(<App />, rootNode);
### ErrorBoundary

`@sentry/react` exports an ErrorBoundary component that will automatically send Javascript errors from inside a
component tree to Sentry, and set a fallback UI. Requires React version >= 16.
component tree to Sentry, and set a fallback UI.

> app.js

```javascript
import React from 'react';
import * as Sentry from '@sentry/react';

function FallbackComponent() {
return (
<div>An error has occured</div>
)
return <div>An error has occured</div>;
}

class App extends React.Component {
Expand All @@ -58,7 +57,7 @@ class App extends React.Component {
<Sentry.ErrorBoundary fallback={FallbackComponent} showDialog>
<OtherComponents />
</Sentry.ErrorBoundary>
)
);
}
}

Expand All @@ -67,11 +66,12 @@ export default App;

### Profiler

`@sentry/react` exports a Profiler component that leverages the tracing features to add React-related
spans to transactions. If tracing is not enabled, the Profiler component will not work. The Profiler
tracks component mount, render duration and updates. Requires React version >= 15.
`@sentry/react` exports a Profiler component that leverages the tracing features to add React-related spans to
transactions. If tracing is not enabled, the Profiler component will not work. The Profiler tracks component mount,
render duration and updates.

> app.js

```javascript
import React from 'react';
import * as Sentry from '@sentry/react';
Expand All @@ -83,7 +83,7 @@ class App extends React.Component {
<InsideComponent someProp={2} />
<AnotherComponent />
</FancyComponent>
)
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"hoist-non-react-statics": "^3.3.2"
},
"peerDependencies": {
"react": "15.x || 16.x || 17.x || 18.x"
"react": "16.x || 17.x || 18.x"
},
"devDependencies": {
"@testing-library/react": "^13.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/errorboundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function setCause(error: Error & { cause?: Error }, cause: Error): void {
}

/**
* A ErrorBoundary component that logs errors to Sentry. Requires React >= 16.
* A ErrorBoundary component that logs errors to Sentry.
* NOTE: If you are a Sentry user, and you are seeing this stack frame, it means the
* Sentry React SDK ErrorBoundary caught an error invoking your application code. This
* is expected behavior and NOT indicative of a bug with the Sentry React SDK.
Expand Down
2 changes: 0 additions & 2 deletions packages/react/test/errorboundary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,6 @@ describe('ErrorBoundary', () => {

describe('isAtLeastReact17', () => {
test.each([
['React 15 with no patch', '15.0', false],
['React 15 with no patch and no minor', '15.5', false],
['React 16', '16.0.4', false],
['React 17', '17.0.0', true],
['React 17 with no patch', '17.4', true],
Expand Down