Skip to content

feat(react): Add React 18 as peer dep #4819

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 5 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
},
"peerDependencies": {
"gatsby": "^2.0.0 || ^3.0.0 || ^4.0.0",
"react": "15.x || 16.x || 17.x"
"react": "15.x || 16.x || 17.x || 18.x"
},
"devDependencies": {
"@sentry/types": "6.19.3",
"@testing-library/react": "^10.4.9",
"react": "^17.0.0"
"@testing-library/react": "^13.0.0-alpha.6",
"react": "^18.0.0"
},
"scripts": {
"build": "run-p build:cjs build:esm build:types",
Expand Down
11 changes: 5 additions & 6 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"tslib": "^1.9.3"
},
"peerDependencies": {
"react": "15.x || 16.x || 17.x"
"react": "15.x || 16.x || 17.x || 18.x"
},
"devDependencies": {
"@testing-library/react": "^11.2.6",
"@testing-library/react-hooks": "^5.1.1",
"@testing-library/react": "^13.0.0-alpha.6",
"@testing-library/react-hooks": "^7.0.2",
"@types/history-4": "npm:@types/[email protected]",
"@types/history-5": "npm:@types/[email protected]",
"@types/hoist-non-react-statics": "^3.3.1",
Expand All @@ -41,12 +41,11 @@
"history-4": "npm:[email protected]",
"history-5": "npm:[email protected]",
"jsdom": "^16.2.2",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-3": "npm:[email protected]",
"react-router-4": "npm:[email protected]",
"react-router-5": "npm:[email protected]",
"react-test-renderer": "^16.13.1",
"redux": "^4.0.5"
},
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/react/test/errorboundary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ describe('isAtLeastReact17', () => {
['React 17', '17.0.0', true],
['React 17 with no patch', '17.4', true],
['React 17 with no patch and no minor', '17', true],
['React 18', '18.0.0', true],
['React 18', '18.1.0', true],
['React 19', '19.0.0', true],
])('%s', (_: string, input: string, output: ReturnType<typeof isAtLeastReact17>) => {
expect(isAtLeastReact17(input)).toBe(output);
});
Expand Down
14 changes: 10 additions & 4 deletions packages/react/test/reactrouterv3.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@testing-library/react';
import { act, render } from '@testing-library/react';
import * as React from 'react';
import { createMemoryHistory, createRoutes, IndexRoute, match, Route, Router } from 'react-router-3';

Expand Down Expand Up @@ -108,7 +108,9 @@ describe('React Router V3', () => {
instrumentation(mockStartTransaction);
const { container } = render(<Router history={history}>{routes}</Router>);

history.push('/users/123');
act(() => {
history.push('/users/123');
});
expect(container.innerHTML).toContain('123');

expect(mockStartTransaction).toHaveBeenCalledTimes(2);
Expand All @@ -124,7 +126,9 @@ describe('React Router V3', () => {
instrumentation(mockStartTransaction);
const { container } = render(<Router history={history}>{routes}</Router>);

history.push('/organizations/1234/v1/758');
act(() => {
history.push('/organizations/1234/v1/758');
});
expect(container.innerHTML).toContain('Team');

expect(mockStartTransaction).toHaveBeenCalledTimes(2);
Expand All @@ -134,7 +138,9 @@ describe('React Router V3', () => {
tags: { from: '/', 'routing.instrumentation': 'react-router-v3' },
});

history.push('/organizations/543');
act(() => {
history.push('/organizations/543');
});
expect(container.innerHTML).toContain('OrgId');

expect(mockStartTransaction).toHaveBeenCalledTimes(3);
Expand Down
32 changes: 20 additions & 12 deletions packages/react/test/reactrouterv4.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@testing-library/react';
import { act, render } from '@testing-library/react';
import { createMemoryHistory } from 'history-4';
import * as React from 'react';
import { matchPath, Route, Router, Switch } from 'react-router-4';
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('React Router v4', () => {

it('does not normalize transaction name ', () => {
const [mockStartTransaction, history] = createInstrumentation();
const { container } = render(
const { getByText } = render(
<Router history={history}>
<Switch>
<Route path="/users/:userid" component={() => <div>UserId</div>} />
Expand All @@ -135,8 +135,10 @@ describe('React Router v4', () => {
</Router>,
);

history.push('/users/123');
expect(container.innerHTML).toContain('UserId');
act(() => {
history.push('/users/123');
});
getByText('UserId');

expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
Expand All @@ -149,7 +151,7 @@ describe('React Router v4', () => {
it('normalizes transaction name with custom Route', () => {
const [mockStartTransaction, history, { mockSetName }] = createInstrumentation();
const SentryRoute = withSentryRouting(Route);
const { container } = render(
const { getByText } = render(
<Router history={history}>
<Switch>
<SentryRoute path="/users/:userid" component={() => <div>UserId</div>} />
Expand All @@ -159,8 +161,10 @@ describe('React Router v4', () => {
</Router>,
);

history.push('/users/123');
expect(container.innerHTML).toContain('UserId');
act(() => {
history.push('/users/123');
});
getByText('UserId');

expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
Expand All @@ -175,7 +179,7 @@ describe('React Router v4', () => {
it('normalizes nested transaction names with custom Route', () => {
const [mockStartTransaction, history, { mockSetName }] = createInstrumentation();
const SentryRoute = withSentryRouting(Route);
const { container } = render(
const { getByText } = render(
<Router history={history}>
<Switch>
<SentryRoute path="/organizations/:orgid/v1/:teamid" component={() => <div>Team</div>} />
Expand All @@ -185,8 +189,10 @@ describe('React Router v4', () => {
</Router>,
);

history.push('/organizations/1234/v1/758');
expect(container.innerHTML).toContain('Team');
act(() => {
history.push('/organizations/1234/v1/758');
});
getByText('Team');

expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
Expand All @@ -197,8 +203,10 @@ describe('React Router v4', () => {
expect(mockSetName).toHaveBeenCalledTimes(2);
expect(mockSetName).toHaveBeenLastCalledWith('/organizations/:orgid/v1/:teamid');

history.push('/organizations/543');
expect(container.innerHTML).toContain('OrgId');
act(() => {
history.push('/organizations/543');
});
getByText('OrgId');

expect(mockStartTransaction).toHaveBeenCalledTimes(3);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
Expand Down
35 changes: 22 additions & 13 deletions packages/react/test/reactrouterv5.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@testing-library/react';
import { act,render } from '@testing-library/react';
import { createMemoryHistory } from 'history-4';
import * as React from 'react';
import { matchPath, Route, Router, Switch } from 'react-router-5';
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('React Router v5', () => {

it('does not normalize transaction name ', () => {
const [mockStartTransaction, history] = createInstrumentation();
const { container } = render(
const { getByText } = render(
<Router history={history}>
<Switch>
<Route path="/users/:userid" component={() => <div>UserId</div>} />
Expand All @@ -135,8 +135,10 @@ describe('React Router v5', () => {
</Router>,
);

history.push('/users/123');
expect(container.innerHTML).toContain('UserId');
act(() => {
history.push('/users/123');
});
getByText('UserId');

expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
Expand All @@ -149,7 +151,8 @@ describe('React Router v5', () => {
it('normalizes transaction name with custom Route', () => {
const [mockStartTransaction, history, { mockSetName }] = createInstrumentation();
const SentryRoute = withSentryRouting(Route);
const { container } = render(

const { getByText } = render(
<Router history={history}>
<Switch>
<SentryRoute path="/users/:userid" component={() => <div>UserId</div>} />
Expand All @@ -158,9 +161,10 @@ describe('React Router v5', () => {
</Switch>
</Router>,
);

history.push('/users/123');
expect(container.innerHTML).toContain('UserId');
act(() => {
history.push('/users/123');
});
getByText('UserId');

expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
Expand All @@ -175,7 +179,8 @@ describe('React Router v5', () => {
it('normalizes nested transaction names with custom Route', () => {
const [mockStartTransaction, history, { mockSetName }] = createInstrumentation();
const SentryRoute = withSentryRouting(Route);
const { container } = render(

const { getByText } = render(
<Router history={history}>
<Switch>
<SentryRoute path="/organizations/:orgid/v1/:teamid" component={() => <div>Team</div>} />
Expand All @@ -185,8 +190,10 @@ describe('React Router v5', () => {
</Router>,
);

history.push('/organizations/1234/v1/758');
expect(container.innerHTML).toContain('Team');
act(() => {
history.push('/organizations/1234/v1/758');
});
getByText('Team');

expect(mockStartTransaction).toHaveBeenCalledTimes(2);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
Expand All @@ -197,8 +204,10 @@ describe('React Router v5', () => {
expect(mockSetName).toHaveBeenCalledTimes(2);
expect(mockSetName).toHaveBeenLastCalledWith('/organizations/:orgid/v1/:teamid');

history.push('/organizations/543');
expect(container.innerHTML).toContain('OrgId');
act(() => {
history.push('/organizations/543');
});
getByText('OrgId');

expect(mockStartTransaction).toHaveBeenCalledTimes(3);
expect(mockStartTransaction).toHaveBeenLastCalledWith({
Expand Down
Loading