Skip to content

Instantly share code, notes, and snippets.

@temoncher
Last active November 5, 2025 21:03
Show Gist options
  • Select an option

  • Save temoncher/3f6191501efaa6a2d607a6c08b56e6d0 to your computer and use it in GitHub Desktop.

Select an option

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