Skip to content

no-useless-use-memo

errorSuggestion

Reports useMemo calls whose result is already static enough to move outside the component.

This rule looks for useMemo calls whose callback returns a value that does not depend on component state, props, or other local render-time values. When that happens, the memo adds overhead without changing the result.

By default, the rule reports empty or omitted dependency arrays only when the returned value is static. Set dependencyMode to "aggressive" if you also want to report static callbacks even when the dependency list is not empty.

Option Type Default What it does
dependencyMode string "non-updating" Chooses whether empty deps only, non-updating deps, or any static memo counts
environment string "roblox-ts" Chooses which React package imports to track
staticGlobalFactories string[] Same as no-useless-use-spring Names treated as static factories when they are otherwise free
Incorrect
import { useMemo } from "react";
const rotationConfiguration = useMemo(
() => getAnimationConfiguration(SpringConfiguration.Sharp, AnimationLibrary.ReactSpring),
[],
);
Correct
const rotationConfiguration = getAnimationConfiguration(
SpringConfiguration.Sharp,
AnimationLibrary.ReactSpring,
);
function Component({ theme }) {
const config = useMemo(() => buildConfig(theme), [theme]);
return config;
}