Created
April 6, 2021 22:16
-
-
Save JuanM04/dd0cf74912e8e5f1c301748828c5a8b1 to your computer and use it in GitHub Desktop.
Sadly, the way to use Generics with forwardRef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Props<T extends unknown> { | |
// ... | |
} | |
export interface MyFormRef<T extends unknown> { | |
// ... | |
} | |
const MyForm = forwardRef(<T extends unknown>(props: Props<T>, ref: Ref<MyFormRef<T>>) => { | |
// some component body here ... | |
}); | |
export default MyForm as <T extends unknown>(props: Props<T> & { ref?: Ref<MyFormRef<T>> }) => JSX.Element; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment