Skip to content

Instantly share code, notes, and snippets.

@JuanM04
Created April 6, 2021 22:16
Show Gist options
  • Save JuanM04/dd0cf74912e8e5f1c301748828c5a8b1 to your computer and use it in GitHub Desktop.
Save JuanM04/dd0cf74912e8e5f1c301748828c5a8b1 to your computer and use it in GitHub Desktop.
Sadly, the way to use Generics with forwardRef
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