askill
do-not-wrap-simple-expression-in-usememo

do-not-wrap-simple-expression-in-usememoSafety 100Repository

Do not wrap a simple expression with a primitive result type in useMemo

0 stars
1.2k downloads
Updated 2/12/2026

Package Files

Loading files...
SKILL.md

Do not wrap a simple expression with a primitive result type in useMemo

When an expression is simple (few logical or arithmetical operators) and has a primitive result type (boolean, number, string), do not wrap it in useMemo. Calling useMemo and comparing hook dependencies may consume more resources than the expression itself.

Incorrect:

function Header({ user, notifications }: Props) {
  const isLoading = useMemo(() => {
    return user.isLoading || notifications.isLoading;
  }, [user.isLoading, notifications.isLoading]);

  if (isLoading) return <Skeleton />;
  // return some markup
}

Correct:

function Header({ user, notifications }: Props) {
  const isLoading = user.isLoading || notifications.isLoading;

  if (isLoading) return <Skeleton />;
  // return some markup
}

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

84/100Analyzed 2/20/2026

Focused React performance skill with clear explanation and code examples. Explains when NOT to use useMemo for simple primitive expressions. Well-structured with contrasting examples, though narrow in scope. Located in a dedicated skills folder within a personal repo.

100
90
70
75
85

Metadata

Licenseunknown
Version-
Updated2/12/2026
Publisherihj04982

Tags

No tags yet.