File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
packages/mui-utils/src/useForkRef Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,9 @@ import * as React from 'react';
19
19
export default function useForkRef < Instance > (
20
20
...refs : Array < React . Ref < Instance > | undefined >
21
21
) : React . RefCallback < Instance > | null {
22
- const cleanupRef = React . useRef < void | ( ( ) => void ) > ( undefined ) ;
22
+ const cleanupRef = React . useRef < ( ) => void > ( undefined ) ;
23
23
24
- const refEffect = React . useCallback ( ( instance : Instance | null ) => {
24
+ const refEffect = React . useCallback ( ( instance : Instance ) => {
25
25
const cleanups = refs . map ( ( ref ) => {
26
26
if ( ref == null ) {
27
27
return null ;
@@ -37,9 +37,9 @@ export default function useForkRef<Instance>(
37
37
} ;
38
38
}
39
39
40
- ( ref as React . RefObject < Instance | null > ) . current = instance ;
40
+ ref . current = instance ;
41
41
return ( ) => {
42
- ( ref as React . RefObject < Instance | null > ) . current = null ;
42
+ ref . current = null ;
43
43
} ;
44
44
} ) ;
45
45
@@ -57,11 +57,11 @@ export default function useForkRef<Instance>(
57
57
return ( value ) => {
58
58
if ( cleanupRef . current ) {
59
59
cleanupRef . current ( ) ;
60
- ( cleanupRef as React . RefObject < void | ( ( ) => void ) > ) . current = undefined ;
60
+ cleanupRef . current = undefined ;
61
61
}
62
62
63
63
if ( value != null ) {
64
- ( cleanupRef as React . RefObject < void | ( ( ) => void ) > ) . current = refEffect ( value ) ;
64
+ cleanupRef . current = refEffect ( value ) ;
65
65
}
66
66
} ;
67
67
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- intentionally ignoring that the dependency array must be an array literal
You can’t perform that action at this time.
0 commit comments