Skip to content

Conversation

@poteto
Copy link
Member

@poteto poteto commented Dec 5, 2025

The current validateNoSetStateInEffects error has potential false positives because
we cannot fully statically detect patterns where calling setState in an effect is
actually valid. This flag enableVerboseNoSetStateInEffect adds a verbose error mode that presents multiple possible
use-cases, allowing an agent to reason about which fix is appropriate before acting:

  1. Non-local derived data - suggests restructuring state ownership
  2. Derived event pattern - suggests requesting an event callback from parent
  3. Force update / external sync - suggests using useSyncExternalStore

This gives agents the context needed to make informed decisions rather than
blindly applying a fix that may not be correct for the specific situation.

@meta-cla meta-cla bot added the CLA Signed label Dec 5, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Dec 5, 2025
…user/agent

The current `validateNoSetStateInEffects` error has potential false positives because
we cannot fully statically detect patterns where calling setState in an effect is
actually valid. This flag `enableVerboseNoSetStateInEffect` adds a verbose error mode that presents multiple possible
use-cases, allowing an agent to reason about which fix is appropriate before acting:

1. Non-local derived data - suggests restructuring state ownership
2. Derived event pattern - suggests requesting an event callback from parent
3. Force update / external sync - suggests using `useSyncExternalStore`

This gives agents the context needed to make informed decisions rather than
blindly applying a fix that may not be correct for the specific situation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants