Skip to content

Commit 7cfd923

Browse files
committed
chore: remove transition from collapse
1 parent b0c7234 commit 7cfd923

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed
Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
1-
import { useEffect, useState, useRef } from 'react'
2-
31
import { CollapseProps } from './types'
42

5-
export const Collapse = ({ expand, onTransitionEnd, children }: CollapseProps) => {
6-
const ref = useRef<HTMLDivElement>(null)
7-
const [contentHeight, setContentHeight] = useState(0)
8-
9-
useEffect(() => {
10-
if (ref.current) {
11-
setContentHeight(ref.current.clientHeight)
12-
}
13-
}, [children])
14-
15-
return (
16-
<div
17-
style={{
18-
height: expand ? contentHeight : 0,
19-
transition: 'height 200ms ease-out',
20-
overflow: 'hidden',
21-
}}
22-
onTransitionEnd={onTransitionEnd}
23-
>
24-
<div ref={ref}>{children}</div>
25-
</div>
26-
)
27-
}
3+
export const Collapse = ({ expand, children }: CollapseProps) => (
4+
// TODO: removed animation because of miscalculations (broken with auto editor height)
5+
<div>{expand ? children : null}</div>
6+
)

0 commit comments

Comments
 (0)