Skip to content

no-useless-use-spring

Reports spring hook calls whose config is static and whose dependencies never update.

By default, this rule checks useSpring. It reports calls where the config object is fully static and the dependency array is missing, omitted, or static. Empty dependency arrays are also reported by default.

Calls with both from and to in the config are skipped, because they can still represent a one-time mount animation.

OptionTypeDefaultWhat it does
springHooksstring[]["useSpring"]Hook names treated as spring hooks
staticGlobalFactoriesstring[]Roblox value constructors such as Vector3, UDim2, Color3, and CFrameNames treated as static constructors
treatEmptyDepsAsViolationbooleantrueReports [] when the config is static
Incorrect
const spring = useSpring({ opacity: 1 });
const DEFAULT_SCALE = 1.5;
const scale = useSpring({ scale: DEFAULT_SCALE }, [DEFAULT_SCALE]);
Correct
const spring = useSpring({ opacity: isOpen ? 1 : 0 }, [isOpen]);
const intro = useSpring({
from: { scale: 0 },
to: { scale: 1 },
}, []);