Repository navigation
v3.9.0
v3.9.0: New no-nested-hook-calls rule for React hook calls
This release adds the no-nested-hook-calls React rule, which reports a hook call placed inside the arguments or callee of another hook call. Existing rules are unchanged.
🚀 Added
- no-nested-hook-calls: The rule reports a hook call nested inside another hook call's arguments, callee, or member chain. For example,
useAttribute(useCharacter(), "Health")reports, and the fix is to assign the inner result to aconstfirst. A hook is a function namedusefollowed by a capital letter or digit, and calls inside a function passed to another hook are not checked. - by @howmanysmall in #105
const character = useCharacter();
const health = useAttribute(character, "Health");The rule is marked recommended in its metadata, so configs that pull in recommended React rules may start reporting existing nested hook calls after upgrading. Hoist each nested call into a const to clear them, or disable the rule.
Full Changelog: v3.8.0...v3.9.0