File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
packages/@headlessui-react/src/internal Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
- import React , { useState } from 'react'
1
+ import React , { cloneElement , isValidElement , useState } from 'react'
2
2
3
- export function Frozen ( { children, freeze } : { children : React . ReactNode ; freeze : boolean } ) {
3
+ function FrozenFn (
4
+ { children, freeze } : { children : React . ReactNode ; freeze : boolean } ,
5
+ ref : React . ForwardedRef < HTMLElement >
6
+ ) {
4
7
let contents = useFrozenData ( freeze , children )
8
+
9
+ if ( isValidElement ( contents ) ) {
10
+ return cloneElement ( contents as React . ReactElement , { ref } )
11
+ }
12
+
5
13
return < > { contents } </ >
6
14
}
7
15
16
+ export const Frozen = React . forwardRef ( FrozenFn )
17
+
8
18
export function useFrozenData < T > ( freeze : boolean , data : T ) {
9
19
let [ frozenValue , setFrozenValue ] = useState ( data )
10
20
You can’t perform that action at this time.
0 commit comments