Skip to content

no-unused-use-memo

Reports useMemo calls whose return value is ignored.

This rule reports useMemo(...) when it is used as a standalone statement, including void useMemo(...). If you are running side effects, use useEffect. If you need memoization, keep and use the returned value.

By default, the rule looks for React imports in the roblox-ts environment. Set environment to "standard" to use react instead.

| Option | Type | Default | What it does | | ------------- | ------------ | ----------- | ------------- | -------------------------------------------- | | environment | "roblox-ts" | "standard" | "roblox-ts" | Chooses which React package imports to track |

Incorrect
import { useMemo } from "react";
useMemo(() => {
trackAnalytics();
}, [eventName]);
void useMemo(() => buildConfig(eventName), [eventName]);
Correct
import { useEffect, useMemo } from "react";
useEffect(() => {
trackAnalytics();
}, [eventName]);
const config = useMemo(() => buildConfig(eventName), [eventName]);