Last active
August 12, 2021 10:02
-
-
Save Enough7/f5ea462be821c216c11f58a74101d36e to your computer and use it in GitHub Desktop.
Generic Hook in ReactTS
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
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