Skip to content

Instantly share code, notes, and snippets.

@Misaka-0x447f
Created October 17, 2023 17:53
Show Gist options
  • Save Misaka-0x447f/3ed0b5f00414b6e55fd3a3512fd08ae0 to your computer and use it in GitHub Desktop.
Save Misaka-0x447f/3ed0b5f00414b6e55fd3a3512fd08ae0 to your computer and use it in GitHub Desktop.
如何处理 forwardedRef 时的泛型。source: https://fettblog.eu/typescript-react-generic-forward-refs/
// TL/DR ⬇️ source: https://fettblog.eu/typescript-react-generic-forward-refs/
const ClickableList = React.forwardRef(ClickableListInner) as <T>(
props: ClickableListProps<T> & { ref?: React.ForwardedRef<HTMLUListElement> }
) => ReturnType<typeof ClickableListInner>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment