A React hook is called inside a callback, such as that of an effect or an array method

tx0/ts:hook-in-nested-callbackrecommendedwarningframeworks/reactdepth fastbug

What it finds

React identifies hooks by the order of their calls during a render. A hook called inside a callback runs when the callback runs, if at all: during an effect, an event, or once per array element, so the order changes and React mixes up the state of hooks.

Reported are calls of use... hooks inside an arrow function or function expression that is passed as an argument, inside a component or hook.

From the rule's source, hook_in_nested_callback.rs.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:hook-in-nested-callback" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:hook-in-nested-callback] reason="..."

tx0 explain tx0/ts:hook-in-nested-callback shows the same in the terminal. Found a false positive? Report it.