react icon indicating copy to clipboard operation
react copied to clipboard

[compiler] Add enableVerboseNoSetStateInEffect to suggest options to user/agent

Open poteto opened this issue 3 months ago • 0 comments

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.

poteto avatar Dec 05 '25 21:12 poteto