Skip to content
Back to skills

309 Rerender Simple Expression In Memo 5bdcf2d1

ASecurity

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.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
toolsexpress

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 309-rerender-simple-expression-in-memo_5bdcf2d1 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 309 Rerender Simple Expression In Memo 5bdcf2d1?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 309 Rerender Simple Expression In Memo 5bdcf2d1
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-309-rerender-simple-expression-in-memo-5bdcf2d1/badge)](https://www.skillsdirectory.com/skills/tools-only-309-rerender-simple-expression-in-memo-5bdcf2d1)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
title: Do not wrap a simple expression with a primitive result type in useMemo
impact: LOW-MEDIUM
impactDescription: wasted computation on every render
tags: rerender, useMemo, optimization
---

## 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:**

```tsx
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:**

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

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

Files in this skill

  • README.md1.2 KB
  • skill.md1018 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…