File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
docs/basic/getting-started Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1730,6 +1730,22 @@ function ClickableListInner<T>(
1730
1730
export const ClickableList = forwardRef (ClickableListInner );
1731
1731
```
1732
1732
1733
+ ##### Option 3 - Call signature
1734
+
1735
+ ``` ts
1736
+ // Add to `index.d.ts`
1737
+ interface ForwardRefWithGenerics extends React .FC <WithForwardRefProps <Option >> {
1738
+ <T extends Option >(props : WithForwardRefProps <T >): ReturnType <
1739
+ React .FC <WithForwardRefProps <T >>
1740
+ >;
1741
+ }
1742
+
1743
+ export const ClickableListWithForwardRef: ForwardRefWithGenerics =
1744
+ forwardRef (ClickableList );
1745
+ ```
1746
+
1747
+ Credits: https://stackoverflow.com/a/73795494
1748
+
1733
1749
#### More Info
1734
1750
1735
1751
- https://medium.com/@martin_hotell/react-refs-with-typescript-a32d56c4d315
Original file line number Diff line number Diff line change @@ -129,6 +129,22 @@ function ClickableListInner<T>(
129
129
export const ClickableList = forwardRef (ClickableListInner );
130
130
```
131
131
132
+ ### Option 3 - Call signature
133
+
134
+ ``` ts
135
+ // Add to `index.d.ts`
136
+ interface ForwardRefWithGenerics extends React .FC <WithForwardRefProps <Option >> {
137
+ <T extends Option >(props : WithForwardRefProps <T >): ReturnType <
138
+ React .FC <WithForwardRefProps <T >>
139
+ >;
140
+ }
141
+
142
+ export const ClickableListWithForwardRef: ForwardRefWithGenerics =
143
+ forwardRef (ClickableList );
144
+ ```
145
+
146
+ Credits: https://stackoverflow.com/a/73795494
147
+
132
148
## More Info
133
149
134
150
- https://medium.com/@martin_hotell/react-refs-with-typescript-a32d56c4d315
You can’t perform that action at this time.
0 commit comments