noctcore-react/no-jsx-in-hooks
A
use*-named function must not return JSX — that is a component wearing a hook costume.
Recommended preset: error · Autofix: no · Suggestions: no · Type information: not needed
Hooks return data and handlers; components return markup. A use*-named function that returns JSX
is a component mislabelled as a hook — it breaks the rules-of-hooks mental model (you would have to
render it as <useThing />) and quietly defeats every convention keyed off the use* prefix.
Rename it to a PascalCase component, or return values instead of elements.
What it flags
Section titled “What it flags”A function whose declared name matches the hook pattern (useX) whose own body returns JSX —
directly, or through a ternary / &&:
// a "hook" that returns markupfunction useUserBadge(user) { return <span>{user.name}</span>;}// a hook returns datafunction useUserBadge(user) { return { label: user.name };}
// this is a component: name it like onefunction UserBadge({ user }) { return <span>{user.name}</span>;}What it does not flag
Section titled “What it does not flag”Returns inside nested functions (render callbacks, .map bodies) belong to those functions, not
the hook, and are not attributed to it. Also left alone:
- a hook returning data, a primitive, or the result of a call such as
useMemo(() => <X />, []); - a PascalCase component returning JSX.
When not to use it
Section titled “When not to use it”If you intentionally build element-returning helpers under a use* name, this rule will fight you —
but the more idiomatic fix is to rename them to PascalCase components.