React Effect Decision logo

React Effect Decision

Community
waynesutton
react-effect-decision

Combine React's official "You Might Not Need an Effect" guidance with this project's stricter no direct useEffect stance. Use when writing, reviewing, or refactoring React components that might reach for useEffect, derived state, event relays, reset logic, subscriptions, or client fetching.

Overview

Publisherwaynesutton
Repositorymarkdown-site
Skill namereact-effect-decision
Stars
627
Forks
91
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by waynesutton on GitHub. Read the source before you install it.

Installation

Install the React Effect Decision AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/waynesutton/markdown-site/tree/main/.claude/react-effect-decision
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/waynesutton/markdown-site.git /tmp/markdown-site
mkdir -p .claude/skills
cp -r /tmp/markdown-site/.claude/react-effect-decision .claude/skills/react-effect-decision
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable React Effect Decision in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads React Effect Decision on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so React Effect Decision is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

React effect decision

Default rule for this project: do not reach for direct useEffect first.

Most effect usage in React code is a sign that the component is syncing state that should be derived during render, routing an event through state, or resetting local state in a way React already models better.

This skill merges:

  • React's official decision tree from "You Might Not Need an Effect"
  • The project's stricter no direct useEffect preference

Start here

Before writing any effect, ask these in order:

  1. Can I calculate this from props or state during render
  2. Is this triggered by a user action and better placed in the event handler
  3. Am I trying to reset component state when identity changed and should use key
  4. Is this an expensive pure calculation that should use useMemo
  5. Is this an external subscription that should use useSyncExternalStore or a focused custom hook
  6. Is this real external synchronization that must happen on mount or on dependency changes

If you answer yes to any of 1 through 5, do not write a direct useEffect.

Project stance

React allows effects for real external synchronization. This project is stricter:

  • Avoid direct useEffect in components whenever a clearer pattern exists
  • Prefer derived values, event handlers, key remounts, memoization, query libraries, Convex hooks, and focused custom hooks
  • If mount only external setup is truly needed, use an explicit useMountEffect wrapper instead of sprinkling raw useEffect through feature code

Example wrapper:

ts
import { useEffect } from "react";

export function useMountEffect(effect: () => void | (() => void)) {
  useEffect(effect, []);
}

Use that only for one time external setup like DOM focus, third party widgets, or browser API listeners that belong to the component lifecycle.

Decision guide

1. Derived state belongs in render

Bad smell:

  • useEffect(() => setX(deriveFromY(y)), [y])
  • State that only mirrors props or other state

Do this instead:

tsx
function TodoList({ todos, showActive }: Props) {
  const activeTodos = todos.filter((todo) => !todo.completed);
  const visibleTodos = showActive ? activeTodos : todos;

  return <List items={visibleTodos} />;
}

If it can be calculated from existing inputs, keep it out of state.

2. Expensive pure calculations use useMemo

If the calculation is pure and expensive, memoize it instead of syncing it into state:

tsx
const visibleTodos = useMemo(
  () => getVisibleTodos(todos, showActive),
  [todos, showActive],
);

Use memoization only when there is real repeated work to skip.

3. Event caused work belongs in the event handler

Bad smell:

  • Set a flag in state
  • Wait for an effect to notice the flag
  • Reset the flag after the side effect runs

Do this instead:

tsx
function PurchaseButton({ product }: Props) {
  async function handleClick() {
    await addToCart(product);
    showNotification(`Added ${product.name}`);
  }

  return <button onClick={handleClick}>Buy</button>;
}

If the work happens because the user clicked, submitted, dragged, or selected, keep it in the handler.

4. Reset with key, not effect choreography

Bad smell:

  • useEffect(() => setFormState(initialFromProps), [id])

Do this instead:

tsx
function EditContact({ contact, onSave }: Props) {
  return <EditContactForm key={contact.id} contact={contact} onSave={onSave} />;
}

If a different entity should feel like a fresh component instance, give the inner component a key.

5. Adjusting state from prop changes is a last resort

If you cannot derive it and do not want a full remount, adjust the state during render of the same component before children render stale data.

Prefer these, in order:

  1. Derive it
  2. Reset with key
  3. Store an ID and derive the selected object from current inputs
  4. Only then use a guarded render time adjustment pattern

6. Data fetching should use the app's data layer or a focused hook

Bad smell:

  • Raw fetch(...).then(setState) inside a component effect
  • Manual loading, retry, cancellation, and stale response handling in feature code

Preferred options:

  • Use Convex React hooks where the data already lives in Convex
  • Use the project's existing data abstraction or a query library for remote APIs
  • If raw client fetching is unavoidable, isolate it inside a custom hook and handle stale response cleanup

Example custom hook pattern:

tsx
function useSearchResults(url: string) {
  const [data, setData] = useState<Result[] | null>(null);

  useEffect(() => {
    let ignore = false;

    fetch(url)
      .then((response) => response.json())
      .then((json) => {
        if (!ignore) {
          setData(json);
        }
      });

    return () => {
      ignore = true;
    };
  }, [url]);

  return data;
}

That is still less preferred than a dedicated query layer, but better than scattering raw fetch effects across components.

7. External subscriptions should use useSyncExternalStore

For browser or third party stores, prefer the React built in subscription model:

tsx
function useOnlineStatus() {
  return useSyncExternalStore(
    subscribe,
    () => navigator.onLine,
    () => true,
  );
}

This is clearer and safer than mirroring an external mutable source through ad hoc effect code.

8. True external synchronization is the narrow allowed case

An effect or useMountEffect is appropriate when the component must synchronize with something outside React:

  • DOM focus or scroll positioning
  • Third party widget setup and cleanup
  • Browser API subscriptions
  • Network synchronization that should happen because the component is on screen, not because a user event fired

When you use one, document the external system in a comment or nearby helper.

Quick smell test

If you are about to write useEffect, check:

  • Is this just derived state
  • Is this event specific logic
  • Is this a reset that should use key
  • Is this a pure expensive calculation
  • Is this a subscription better modeled with useSyncExternalStore
  • Is this data loading that belongs in Convex, a query library, or a custom hook
  • What external system am I synchronizing with

If you cannot name the external system, you probably do not need an effect.

Code review prompts

Use these during review:

  • What breaks if this effect is removed and the value is derived during render
  • Is this component storing data that can be recomputed from props or state
  • Why is this work not in the click, submit, or change handler that caused it
  • Would key={entityId} remove the reset logic entirely
  • Should this be a custom hook instead of inline effect code
  • Is this component talking to an external system, or only to React state

Summary

The safest path in this repo is simple:

  • Derive during render when possible
  • Handle user caused work in handlers
  • Reset with key
  • Memoize expensive pure work
  • Use dedicated hooks for fetching and subscriptions
  • Reserve effect style lifecycle code for real external synchronization

Sources:

Frequently asked questions

What does the React Effect Decision AI skill do?

Combine React's official "You Might Not Need an Effect" guidance with this project's stricter no direct useEffect stance. Use when writing, reviewing, or refactoring React components that might reach for useEffect, derived state, event relays, reset logic, subscriptions, or client fetching.

Why use React Effect Decision on TypingMind?

Because you install it once and use it with any model. React Effect Decision is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install React Effect Decision in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/waynesutton/markdown-site/tree/main/.claude/react-effect-decision. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use React Effect Decision?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with React Effect Decision?

As many as you like. As long as a model supports skills, you can use React Effect Decision with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the React Effect Decision AI skill free?

Yes. It is published on GitHub by waynesutton under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇