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'
22
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+ ) {
47 let contents = useFrozenData ( freeze , children )
8+
9+ if ( isValidElement ( contents ) ) {
10+ return cloneElement ( contents as React . ReactElement , { ref } )
11+ }
12+
513 return < > { contents } </ >
614}
715
16+ export const Frozen = React . forwardRef ( FrozenFn )
17+
818export function useFrozenData < T > ( freeze : boolean , data : T ) {
919 let [ frozenValue , setFrozenValue ] = useState ( data )
1020
You can’t perform that action at this time.
0 commit comments