Skip to content

Instantly share code, notes, and snippets.

@temoncher
Last active April 13, 2024 12:13
Show Gist options
  • Save temoncher/3f6191501efaa6a2d607a6c08b56e6d0 to your computer and use it in GitHub Desktop.
Save temoncher/3f6191501efaa6a2d607a6c08b56e6d0 to your computer and use it in GitHub Desktop.
UseHook component
// TODO: make eslint rule only allowing to UseHook inside client components
// TODO: make eslint rule not allowing conditions inside useHook
export function UseHook<T>(props: {
useHook: () => T;
children: (hookResult: T) => JSX.Element;
}) {
const hookResult = props.useHook();
return <>{props.children(hookResult)}</>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment