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

Remove unnecessary useMemo calls for simple expressions in React components.

Updated Feb 10, 2026
One-click install
npx skills add https://github.com/ihj04982/my-cursor-settings --skill do-not-wrap-simple-expression-in-usememo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: do-not-wrap-simple-expression-in-usememo
Source: https://github.com/ihj04982/my-cursor-settings/tree/main/skills/do-not-wrap-simple-expression-in-usememo
Command: npx skills add https://github.com/ihj04982/my-cursor-settings --skill do-not-wrap-simple-expression-in-usememo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents unnecessary performance overhead in React applications by avoiding the misuse of useMemo for simple expressions that return primitive values.

Core Features & Use Cases

  • Performance Optimization: Identifies and corrects instances where useMemo is applied to simple calculations or boolean checks, which can be less efficient than direct computation.
  • Code Clarity: Promotes cleaner and more readable React code by adhering to best practices for hook usage.
  • Use Case: Refactor a React component to remove a useMemo hook that is wrapping a simple boolean logic, improving rendering performance.

Quick Start

Refactor the provided React component to remove unnecessary useMemo calls for simple expressions.

Frequently Asked Questions about do-not-wrap-simple-expression-in-usememo

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does wrapping a simple expression in useMemo hurt React performance?

Wrapping simple expressions in useMemo reduces React rendering efficiency because the hook's overhead exceeds the minimal computational cost of directly evaluating primitive values.

When should I not use useMemo in a React component?

You should not use useMemo when calculating simple expressions that yield primitive types, as the hook overhead outweighs the computational cost and degrades rendering performance.

How do I refactor my React code to remove unnecessary useMemo?

To remove unnecessary useMemo, refactor your React component to compute simple boolean logic and primitive calculations directly instead of wrapping them in the hook, yielding cleaner code.

Does useMemo work with primitive values for performance optimization?

useMemo does not work well for primitive values because applying it to simple boolean logic or calculations creates performance overhead that exceeds the direct computational cost.

What is the best way to optimize React hook usage for simple calculations?

The best way to optimize React hook usage is to eliminate useMemo for simple calculations, enforcing best practices by computing primitive types directly to improve rendering efficiency.