Skip to content

Commit 13b012e

Browse files
deps: react-migration-to-v19 (#6764)
Co-authored-by: Talisson <talisson.odcosta@gmail.com>
1 parent a8a876c commit 13b012e

28 files changed

Lines changed: 805 additions & 1922 deletions

frontend/.babelrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"presets": [
3-
"@babel/preset-react",
3+
["@babel/preset-react", { "runtime": "automatic" }],
44
"@babel/preset-typescript",
55
[
66
"@babel/preset-env",
@@ -33,8 +33,7 @@
3333
"production": {
3434
"plugins": [
3535
"transform-react-remove-prop-types",
36-
"@babel/transform-react-constant-elements",
37-
"@babel/transform-react-inline-elements"
36+
"@babel/transform-react-constant-elements"
3837
]
3938
}
4039
}

frontend/common/Component.js

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { useEffect, useRef, useState } from 'react'
2+
3+
/**
4+
* Hook for animating height transitions (expand/collapse).
5+
*
6+
* Uses a double requestAnimationFrame on collapse to ensure the browser
7+
* paints the current scrollHeight before transitioning to 0.
8+
*/
9+
export default function useCollapsibleHeight(open: boolean) {
10+
const contentRef = useRef<HTMLDivElement>(null)
11+
const [height, setHeight] = useState<number | undefined>(open ? undefined : 0)
12+
13+
useEffect(() => {
14+
if (!contentRef.current) return
15+
if (open) {
16+
setHeight(contentRef.current.scrollHeight)
17+
const timer = setTimeout(() => setHeight(undefined), 300)
18+
return () => clearTimeout(timer)
19+
} else {
20+
setHeight(contentRef.current.scrollHeight)
21+
let innerFrameId: number
22+
const outerFrameId = requestAnimationFrame(() => {
23+
innerFrameId = requestAnimationFrame(() => {
24+
setHeight(0)
25+
})
26+
})
27+
return () => {
28+
cancelAnimationFrame(outerFrameId)
29+
cancelAnimationFrame(innerFrameId)
30+
}
31+
}
32+
}, [open])
33+
34+
const style = {
35+
height: height !== undefined ? `${height}px` : 'auto',
36+
overflow: 'hidden' as const,
37+
transition: 'height 0.3s ease',
38+
}
39+
40+
return { contentRef, style }
41+
}

frontend/common/providers/ConfigProvider.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export default (WrappedComponent) => {
2828

2929
return (
3030
<WrappedComponent
31-
ref='wrappedComponent'
3231
isLoading={isLoading}
3332
error={error}
3433
history={this.props.history}

frontend/common/providers/withSegmentOverrides.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ export default (WrappedComponent) => {
225225
render() {
226226
return (
227227
<WrappedComponent
228-
ref='wrappedComponent'
229228
updateSegments={this.updateSegments}
230229
onEnvironmentVariationsChange={this.onEnvironmentVariationsChange}
231230
removeMultivariateOption={this.removeMultivariateOption}

0 commit comments

Comments
 (0)