Skip to content

Instantly share code, notes, and snippets.

@Enough7
Last active August 12, 2021 10:02
Show Gist options
  • Save Enough7/f5ea462be821c216c11f58a74101d36e to your computer and use it in GitHub Desktop.
Save Enough7/f5ea462be821c216c11f58a74101d36e to your computer and use it in GitHub Desktop.
Generic Hook in ReactTS
import {Fragment} from "react";
interface IGenericHookProps<TData> {
data: TData,
}
// Trailing comma in <TData,> to sidestep/avoid the JSX ambiguity. Only works in newer TypeScript-Compilers. Source: https://stackoverflow.com/questions/32308370/what-is-the-syntax-for-typescript-arrow-functions-with-generics#comment99104831_45576880
export let GenericHook = <TData,>(props: PropsWithChildren<IGenericHookProps<TData>>): JSX.Element => {
return (
<Fragment></Fragment>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment