Skip to content

no-useless-use-memo

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.

OptionTypeDefaultWhat it does
dependencyModestring"non-updating"Chooses whether empty deps only, non-updating deps, or any static memo counts
environmentstring"roblox-ts"Chooses which React package imports to track
staticGlobalFactoriesstring[]Same as no-useless-use-springNames 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;
}