File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ export { default as useCombinedRefs } from './useCombinedRefs' ;
1
2
export { default as useToggleValue } from './useToggleValue' ;
2
3
export { default as useDidUpdate } from './useDidUpdate' ;
3
4
export { default as useOrientation } from './useOrientation' ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ declare const useCombinedRefs : ( ...refs : React . Ref < any > [ ] ) => React . MutableRefObject < undefined > ;
3
+ export default useCombinedRefs ;
Original file line number Diff line number Diff line change
1
+ export { default as useCombinedRefs } from './useCombinedRefs' ;
1
2
export { default as useToggleValue } from './useToggleValue' ;
2
3
export { default as useDidUpdate } from './useDidUpdate' ;
3
4
export { default as useOrientation } from './useOrientation' ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ const useCombinedRefs = ( ...refs : React . Ref < any > [ ] ) => {
4
+ const targetRef = React . useRef ( ) ;
5
+
6
+ React . useEffect ( ( ) => {
7
+ refs . forEach ( ref => {
8
+ if ( ! ref ) {
9
+ return ;
10
+ }
11
+
12
+ if ( typeof ref === 'function' ) {
13
+ ref ( targetRef . current ) ;
14
+ } else {
15
+ // @ts -expect-error
16
+ ref . current = targetRef . current ;
17
+ }
18
+ } ) ;
19
+ } , [ refs ] ) ;
20
+
21
+ return targetRef ;
22
+ } ;
23
+
24
+ export default useCombinedRefs ;
You can’t perform that action at this time.
0 commit comments