File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
packages/utils/error-overlay/src/components Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 66 */
77
88/* @flow */
9- import { useState } from 'preact/hooks' ;
9+ import { useRef } from 'preact/hooks' ;
1010import { theme } from '../styles' ;
1111
1212const _collapsibleStyle = {
@@ -40,15 +40,12 @@ type CollapsiblePropsType = {|
4040| } ;
4141
4242function Collapsible ( props : CollapsiblePropsType ) : React$Element < 'details' > {
43- const [ collapsed , setCollapsed ] = useState ( true ) ;
44-
45- const toggleCollapsed = ( ) => {
46- setCollapsed ( ! collapsed ) ;
47- } ;
43+ const ref = useRef ( null ) ;
44+ const collapsed = ref . current ?. open ;
4845
4946 const count = props . children . length ;
5047 return (
51- < details open = { ! collapsed } onToggle = { toggleCollapsed } >
48+ < details >
5249 < summary
5350 style = { collapsed ? collapsibleCollapsedStyle : collapsibleExpandedStyle }
5451 >
@@ -58,7 +55,10 @@ function Collapsible(props: CollapsiblePropsType): React$Element<'details'> {
5855 </ summary >
5956 < div >
6057 { props . children }
61- < button onClick = { toggleCollapsed } style = { collapsibleExpandedStyle } >
58+ < button
59+ onClick = { ( ) => ref . current ?. setAttribute ( 'open' , false ) }
60+ style = { collapsibleExpandedStyle }
61+ >
6262 { `▲ ${ count } stack frames were expanded.` }
6363 </ button >
6464 </ div >
You can’t perform that action at this time.
0 commit comments