SIGN IN SIGN UP
facebook / react UNCLAIMED

The library for web and native user interfaces.

0 0 0 JavaScript

[compiler] Add enableVerboseNoSetStateInEffect to suggest options to user/agent (#35306)

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.

DiffTrain build for [3640f38a728f3a057649cf7aec65a6ce14c2eac0](https://github.com/facebook/react/commit/3640f38a728f3a057649cf7aec65a6ce14c2eac0)
P
poteto committed
ceeb16e0eebb31be7596327227fbc045735943dd
Parent: 8c6a0bd