Created
February 15, 2023 23:33
-
-
Save thewisenerd/d6b3349ffd1fe861a811aa174f768a18 to your computer and use it in GitHub Desktop.
This file contains 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 ExtractHookProps<T> { | |
extractor: () => T; | |
setup: (hookValue: T) => void; | |
} | |
function ExtractHook<T>(props: React.PropsWithChildren<ExtractHookProps<T>>) { | |
let {extractor, setup, ...others} = props; | |
let hookValue = extractor(); | |
setup(hookValue); | |
return <div {...others} /> | |
} |
Author
thewisenerd
commented
Feb 15, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment