no-useless-use-memo
Reports useMemo calls whose result is already static enough to move outside the component.
Rule details Suggestion
Section titled “Rule details ”SuggestionThis 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.
Options
Section titled “Options”| 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 |
Examples
Section titled “Examples” 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;}Related rules
Section titled “Related rules” no-unused-use-memo Reports discarded useMemo results
no-useless-use-spring Reports spring hooks with static inputs
React Docs: useMemo Official reference for useMemo