File tree Expand file tree Collapse file tree 1 file changed +26
-10
lines changed Expand file tree Collapse file tree 1 file changed +26
-10
lines changed Original file line number Diff line number Diff line change 1
- import { ForwardedRef , forwardRef } from "react" ;
1
+ import { ForwardedRef , forwardRef , useRef } from "react" ;
2
2
import { Equal , Expect } from "../helpers/type-utils" ;
3
3
4
4
type Props < T > = {
@@ -31,20 +31,36 @@ type Props<T> = {
31
31
* By doing it this way, we preserve the generic context of the function
32
32
* being passed in.
33
33
*/
34
- export const Table = < T , > ( props : Props < T > , ref : ForwardedRef < any > ) => {
35
- return null ;
34
+ export const Table = < T , > (
35
+ props : Props < T > ,
36
+ ref : ForwardedRef < HTMLTableElement > ,
37
+ ) => {
38
+ return < table ref = { ref } /> ;
36
39
} ;
37
40
38
41
const ForwardReffedTable = forwardRef ( Table ) ;
39
42
40
43
const Parent = ( ) => {
44
+ const tableRef = useRef < HTMLTableElement > ( null ) ;
45
+ const wrongRef = useRef < HTMLDivElement > ( null ) ;
41
46
return (
42
- < ForwardReffedTable
43
- data = { [ "123" ] }
44
- renderRow = { ( row ) => {
45
- type test = Expect < Equal < typeof row , string > > ;
46
- return < div > 123</ div > ;
47
- } }
48
- > </ ForwardReffedTable >
47
+ < >
48
+ < ForwardReffedTable
49
+ ref = { tableRef }
50
+ data = { [ "123" ] }
51
+ renderRow = { ( row ) => {
52
+ type test = Expect < Equal < typeof row , string > > ;
53
+ return < div > 123</ div > ;
54
+ } }
55
+ />
56
+ < ForwardReffedTable
57
+ // @ts -expect-error
58
+ ref = { wrongRef }
59
+ data = { [ "123" ] }
60
+ renderRow = { ( row ) => {
61
+ return < div > 123</ div > ;
62
+ } }
63
+ />
64
+ </ >
49
65
) ;
50
66
} ;
You can’t perform that action at this time.
0 commit comments