redux-selector-rules

Enforce Redux selector patterns to prevent unnecessary re-renders.

2|1|Updated Aug 24, 2024
One-click install
npx skills add https://github.com/armanisadeghi/ai-matrx --skill redux-selector-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: redux-selector-rules
Source: https://github.com/armanisadeghi/ai-matrx/tree/main/.cursor/skills/redux-selector-rules
Command: npx skills add https://github.com/armanisadeghi/ai-matrx --skill redux-selector-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Redux selector performance issues cause unnecessary re-renders, wasted computations, and render loops in React apps.

Core Features & Use Cases

  • Rule-based selector patterns to avoid returning new object references on every call.
  • Input vs. result selector discipline to split logic so input selectors return primitives and result functions derive data.
  • Migration guidance & debugging tips to identify and fix performance bottlenecks across the codebase.

Quick Start

Audit your selectors to ensure input selectors return primitive values and move transformations to result functions.

Frequently Asked Questions about redux-selector-rules

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

FAQPage Schema
How do I fix unnecessary re-renders caused by Redux selectors?

Fix Redux selector unnecessary re-renders by ensuring input selectors return primitive values and moving transformations to result functions. This prevents returning new object references on every call, which triggers wasted computations and render loops in React apps.

Why does my useSelector hook keep returning new object references?

Your useSelector hook returns new object references because transformations are likely placed in input selectors instead of result functions. Move data transformations to result functions and ensure input selectors return primitives to prevent unnecessary re-renders.

How do I structure createSelector input and result selectors correctly?

Structure createSelector by splitting logic so input selectors return primitive values and result functions derive data. This input versus result selector discipline ensures memoization works correctly and prevents performance bottlenecks across your React-Redux app.

Does this approach work with useAppSelector calls in React-Redux apps?

Yes, these selector rules apply to useSelector and useAppSelector calls in React-Redux apps. Enforcing input-selector discipline and avoiding default values in selectors prevents unnecessary re-renders across the codebase.

What is the best way to debug Redux selector performance bottlenecks?

Debug Redux selector performance bottlenecks by auditing your selectors to verify input selectors return primitives. Apply migration guidance to identify and fix performance issues by moving transformations to result functions and avoiding default values in selectors.