Skip to content

Commit ab42a12

Browse files
authored
chore: Bump react dev dep, and move more things to catalog (#2707)
* Bump react dev dep, and move more things to catalog * Fix leaking react deps into react-native package * Add JSX to import * Fix * Fix * Fix * Fix * Stack trace size can vary * Fix * Add eslint ignore * Use consistent babel versions
1 parent 0188345 commit ab42a12

File tree

17 files changed

+1438
-2603
lines changed

17 files changed

+1438
-2603
lines changed

packages/browser/package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@
5656
"web-vitals": "^4.2.4"
5757
},
5858
"devDependencies": {
59-
"@babel/core": "7.27.1",
60-
"@babel/plugin-syntax-decorators": "^7.27.1",
61-
"@babel/plugin-transform-exponentiation-operator": "^7.27.1",
62-
"@babel/plugin-transform-nullish-coalescing-operator": "^7.27.1",
63-
"@babel/plugin-transform-react-jsx": "^7.27.1",
64-
"@babel/preset-env": "7.27.2",
65-
"@babel/preset-typescript": "^7.27.1",
59+
"@babel/core": "catalog:",
60+
"@babel/plugin-syntax-decorators": "catalog:",
61+
"@babel/plugin-transform-exponentiation-operator": "catalog:",
62+
"@babel/plugin-transform-nullish-coalescing-operator": "catalog:",
63+
"@babel/plugin-transform-react-jsx": "catalog:",
64+
"@babel/preset-env": "catalog:",
65+
"@babel/preset-typescript": "catalog:",
6666
"@jest/globals": "^29.7.0",
6767
"@playwright/test": "^1.52.0",
6868
"@posthog-tooling/rollup-utils": "workspace:*",
@@ -79,11 +79,11 @@
7979
"@rrweb/rrweb-plugin-console-record": "2.0.0-alpha.17",
8080
"@rrweb/types": "2.0.0-alpha.17",
8181
"@sentry/types": "8.7.0",
82-
"@testing-library/dom": "^9.3.0",
83-
"@testing-library/jest-dom": "^6.5.0",
84-
"@testing-library/preact": "^3.2.4",
82+
"@testing-library/dom": "catalog:",
83+
"@testing-library/jest-dom": "catalog:",
84+
"@testing-library/preact": "catalog:",
8585
"@types/dotenv": "^8.2.3",
86-
"@types/jest": "^29.5.12",
86+
"@types/jest": "catalog:",
8787
"@types/node": "^22.5.0",
8888
"@types/sinon": "^17.0.1",
8989
"@types/web": "^0.0.222",
@@ -98,8 +98,8 @@
9898
"http-server": "14.1.1",
9999
"husky": "^8.0.1",
100100
"identity-obj-proxy": "^3.0.0",
101-
"jest": "^29.7.0",
102-
"jest-environment-jsdom": "^29.7.0",
101+
"jest": "catalog:",
102+
"jest-environment-jsdom": "catalog:",
103103
"jsdom": "16.7.0",
104104
"jsdom-global": "3.0.2",
105105
"localStorage": "1.0.4",
@@ -110,7 +110,7 @@
110110
"postcss-nesting": "^13.0.1",
111111
"posthog-js": "link:",
112112
"preact-render-to-string": "^6.3.1",
113-
"rollup": "^4.50.0",
113+
"rollup": "catalog:",
114114
"rollup-plugin-dts": "^6.2.3",
115115
"rollup-plugin-postcss": "^4.0.2",
116116
"rollup-plugin-visualizer": "^6.0.3",

packages/react-native/src/surveys/icons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import React, { JSX } from 'react'
22
import { Path, Svg, SvgProps } from 'react-native-svg'
33

44
export const SatisfiedEmoji = (props: SvgProps): JSX.Element => (

packages/react-native/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
"skipLibCheck": true,
1515
"sourceMap": true,
1616
"strict": true,
17-
"target": "ES2018"
17+
"target": "ES2018",
18+
"paths": {
19+
"react": ["./node_modules/@types/react"],
20+
"react-native": ["./node_modules/react-native"]
21+
}
1822
},
1923
"include": ["index.ts", "src/**/*.ts", "src/**/*.tsx"]
2024
}

packages/react/babel.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
module.exports = {
2-
presets: [['@babel/preset-env', { targets: { node: '18.0' } }], '@babel/preset-typescript', '@babel/preset-react'],
2+
presets: [
3+
['@babel/preset-env', { targets: { node: '18.0' } }],
4+
['@babel/preset-typescript', { allowDeclareFields: true }],
5+
'@babel/preset-react',
6+
],
37
}

packages/react/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@
3939
}
4040
},
4141
"devDependencies": {
42-
"@babel/preset-react": "^7.18.6",
42+
"@babel/preset-react": "catalog:",
4343
"@posthog-tooling/rollup-utils": "workspace:*",
4444
"@rollup/plugin-inject": "^4.0.2",
4545
"@rollup/plugin-replace": "^2.3.4",
46-
"@testing-library/jest-dom": "^6.9.1",
47-
"@testing-library/react": "^11.2.2",
48-
"@testing-library/react-hooks": "^8.0.1",
49-
"@types/react": "^17.0.0",
46+
"@testing-library/dom": "catalog:",
47+
"@testing-library/jest-dom": "catalog:",
48+
"@testing-library/react": "catalog:",
49+
"@types/react": "catalog:",
5050
"@types/jest": "catalog:",
5151
"cross-env": "^7.0.3",
5252
"jest": "catalog:",
5353
"jest-environment-jsdom": "catalog:",
5454
"posthog-js": "workspace:*",
55-
"react": "^17.0.1",
56-
"react-dom": "^17.0.1",
57-
"react-test-renderer": "^17.0.1",
55+
"react": "catalog:",
56+
"react-dom": "catalog:",
57+
"react-test-renderer": "catalog:",
5858
"rollup": "^2.35.1",
5959
"rollup-plugin-copy": "^3.5.0",
6060
"tslib": "catalog:",

packages/react/src/components/PostHogCaptureOnViewed.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Children, useCallback, useRef } from 'react'
1+
import React, { Children, useCallback, useRef, JSX } from 'react'
22
import { usePostHog } from '../hooks'
33
import { VisibilityAndClickTracker } from './internal/VisibilityAndClickTracker'
44

packages/react/src/components/PostHogErrorBoundary.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const __POSTHOG_ERROR_MESSAGES = {
3535

3636
export class PostHogErrorBoundary extends React.Component<PostHogErrorBoundaryProps, PostHogErrorBoundaryState> {
3737
static contextType = PostHogContext
38+
declare context: React.ContextType<typeof PostHogContext>
3839

3940
constructor(props: PostHogErrorBoundaryProps) {
4041
super(props)
@@ -56,7 +57,7 @@ export class PostHogErrorBoundary extends React.Component<PostHogErrorBoundaryPr
5657
const { componentStack } = errorInfo
5758
this.setState({
5859
error,
59-
componentStack,
60+
componentStack: componentStack ?? null,
6061
exceptionEvent,
6162
})
6263
}

packages/react/src/components/PostHogFeature.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useFeatureFlagPayload, useFeatureFlagVariantKey, usePostHog } from '../hooks'
2-
import React from 'react'
2+
import React, { JSX } from 'react'
33
import { PostHog } from '../context'
44
import { isFunction, isUndefined } from '../utils/type-utils'
55
import { VisibilityAndClickTrackers } from './internal/VisibilityAndClickTrackers'
66

7-
export type PostHogFeatureProps = React.HTMLProps<HTMLDivElement> & {
7+
export type PostHogFeatureProps = Omit<React.HTMLProps<HTMLDivElement>, 'children'> & {
88
flag: string
99
children: React.ReactNode | ((payload: any) => React.ReactNode)
1010
fallback?: React.ReactNode

packages/react/src/components/__tests__/PostHogErrorBoundary.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ describe('PostHogErrorBoundary component', () => {
1717
const { container } = renderWithError({ message: 'Test error', fallback: <div></div> })
1818
expect(posthog.captureException).toHaveBeenCalledWith(new Error('Test error'), undefined)
1919
expect(container.innerHTML).toBe('<div></div>')
20-
expect(console.error).toHaveBeenCalledTimes(2)
20+
expect(console.error).toHaveBeenCalledTimes(1)
21+
expect((console.error as any).mock.calls[0][1].message).toEqual('Test error')
2122
})
2223

2324
it('should warn user when fallback is null', () => {
@@ -72,7 +73,7 @@ describe('captureException processing', () => {
7273
const exceptionList = captureCalls[0][1].$exception_list
7374
expect(exceptionList.length).toBe(1)
7475
const stacktrace = exceptionList[0].stacktrace
75-
expect(stacktrace.frames.length).toBe(44)
76+
expect(stacktrace.frames.length).toBeGreaterThan(20)
7677
})
7778
})
7879

packages/react/src/components/internal/VisibilityAndClickTracker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { MouseEventHandler, useEffect, useMemo, useRef } from 'react'
1+
import React, { MouseEventHandler, useEffect, useMemo, useRef, JSX } from 'react'
22
import { isNull } from '../../utils/type-utils'
33

44
/**

0 commit comments

Comments
 (0)