you-might-not-need-a-memo
simstudioai/sim/.agents/skills/you-might-not-need-a-memo/SKILL.md
Analyze and fix useMemo/React.memo anti-patterns in your code
Skill30k starsChanged yesterday
What's in it
- You Might Not Need a Memo
- References
- Anti-patterns to detect
- Patterns that ARE correct — do not flag
- Steps
--- name: you-might-not-need-a-memo description: Analyze and fix useMemo/React.memo anti-patterns in your code argument-hint: "[scope] [fix=true|false]" --- # You Might Not Need a Memo Arguments: - scope: what to analyze (default: your current changes). Examples: "diff to main", "PR #123", "src/components/", "whole codebase" - fix: whether to apply fixes (default: true). Set to false to only propose changes. User arguments: $ARGUMENTS ## References Read before analyzing: 1. https://overreacted.io/before-you-memo/ — two techniques to avoid memo entirely ## Anti-patterns to detect 1. **Wrapping a slow component in React.memo when state can be moved down**: If a component re-renders because of state it doesn't use, move that state into a smaller child component instead of memoizing. The slow component stops re-rendering without memo. 2. **Wrapping in React.memo when children can be lifted up**: If a parent owns state that changes frequently, extract the stateful part and pass the expensive subtree as `children`. Children passed as props don't re-render when the parent's state changes. 3. **useMemo on cheap computations**: Filtering or mapping a small array, string concatenation, simple arithmetic — these don't need memoization. Only memoize when you've measured a performance problem. 4. **useMemo with constantly-changing deps**: If the dependency array changes on every render, useMemo does nothing — it recalculates every time. Fix the deps or remove the memo. 5. **useMemo to create objects/arrays passed as props**: Instead of memoizing to prevent child re-renders, consider whether the child even needs referential stability. If the child doesn't use React.memo or pass it to a dep array, the memo is wasted. 6. **React.memo on components that always receive new props**: If the parent always passes new objects, arrays, or callbacks, React.memo's shallow comparison always fails. Fix the parent instead of memoizing the child. 7. **useMemo for derived state**: If you're computing a value from props or state, just compute it inline during render. React renders are fast. `const fullName = first + ' ' + last` doesn't need useMemo. ## Patterns that ARE correct — do not flag - A `useMemo` that builds a lookup `Map`/`Set` or a single-pass partition for list rendering (`.claude/rules/sim-components.md` "List-render performance"). ## Steps 1. Read the reference above to understand the two core techniques (move state down, lift content up) 2. Analyze the specified scope for the anti-patterns listed above 3. If fix=true, apply the fixes. If fix=false, propose the fixes without applying.
More agent context in simstudioai/sim
63 other files this repository gives its agents, the first 60 shown.
AGENTS.md
CLAUDE.md
Cursor rule
- .cursor/rules/constitution.mdc
- .cursor/rules/emcn-components.mdc
- .cursor/rules/landing-seo-geo.mdc
- .cursor/rules/sim-api-contracts.mdc
- .cursor/rules/sim-architecture.mdc
- .cursor/rules/sim-caching.mdc
- .cursor/rules/sim-components.mdc
- .cursor/rules/sim-hooks.mdc
- .cursor/rules/sim-imports.mdc
- .cursor/rules/sim-integrations.mdc
- .cursor/rules/sim-list-ordering.mdc
- .cursor/rules/sim-queries.mdc
- .cursor/rules/sim-react-performance.mdc
- .cursor/rules/sim-sandbox.mdc
- .cursor/rules/sim-settings-pages.mdc
- .cursor/rules/sim-stores.mdc
- .cursor/rules/sim-styling.mdc
- .cursor/rules/sim-testing.mdc
- .cursor/rules/sim-ui-copy.mdc
- .cursor/rules/sim-url-state.mdc
Skill
- add-block-preview.agents/skills/add-block-preview/SKILL.md
- add-block.agents/skills/add-block/SKILL.md
- add-column-type.agents/skills/add-column-type/SKILL.md
- add-connector.agents/skills/add-connector/SKILL.md
- add-enrichment.agents/skills/add-enrichment/SKILL.md
- add-feature-flag.agents/skills/add-feature-flag/SKILL.md
- add-hosted-key.agents/skills/add-hosted-key/SKILL.md
- add-integration.agents/skills/add-integration/SKILL.md
- add-managed-cli.agents/skills/add-managed-cli/SKILL.md
- add-model.agents/skills/add-model/SKILL.md
- add-permission-group-item.agents/skills/add-permission-group-item/SKILL.md
- add-selector.agents/skills/add-selector/SKILL.md
- add-settings-page.agents/skills/add-settings-page/SKILL.md
- add-tools.agents/skills/add-tools/SKILL.md
- add-trigger.agents/skills/add-trigger/SKILL.md
- babysit.agents/skills/babysit/SKILL.md
- cleanup.agents/skills/cleanup/SKILL.md
- council.agents/skills/council/SKILL.md
- db-migrate.agents/skills/db-migrate/SKILL.md
- design-taste-frontend.agents/skills/design-taste-frontend/SKILL.md
- emcn-design-review.agents/skills/emcn-design-review/SKILL.md
- emil-design-eng.agents/skills/emil-design-eng/SKILL.md
- make-interfaces-feel-better.agents/skills/make-interfaces-feel-better/SKILL.md
- memory-load-check.agents/skills/memory-load-check/SKILL.md
- migrate-application-operation.agents/skills/migrate-application-operation/SKILL.md
- react-query-best-practices.agents/skills/react-query-best-practices/SKILL.md
- ship.agents/skills/ship/SKILL.md
- test-audit.agents/skills/test-audit/SKILL.md
- tool-registry-boundary.agents/skills/tool-registry-boundary/SKILL.md
- v2-api-conventions.agents/skills/v2-api-conventions/SKILL.md
- validate-connector.agents/skills/validate-connector/SKILL.md
- validate-integration.agents/skills/validate-integration/SKILL.md
- validate-model.agents/skills/validate-model/SKILL.md
- validate-permission-group-item.agents/skills/validate-permission-group-item/SKILL.md
- validate-selector.agents/skills/validate-selector/SKILL.md
- validate-trigger.agents/skills/validate-trigger/SKILL.md
- you-might-not-need-a-callback.agents/skills/you-might-not-need-a-callback/SKILL.md
- you-might-not-need-a-comment.agents/skills/you-might-not-need-a-comment/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
Reports can't be read right now.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool registry_write, action report. How to connect one.

