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>(
17301730export const ClickableList = forwardRef (ClickableListInner );
17311731```
17321732
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+
17331749#### More Info
17341750
17351751- 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>(
129129export const ClickableList = forwardRef (ClickableListInner );
130130```
131131
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+
132148## More Info
133149
134150- https://medium.com/@martin_hotell/react-refs-with-typescript-a32d56c4d315
You can’t perform that action at this time.
0 commit comments