-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Provide a general summary of the issue here
CC report once we isolated the root cause to be a package json lock regeneration that installed @react-stately/utils at version 3.11.0:
PR #9331 (merged December 11, 2025) introduced the rerender loop issue.
The Problem Chain
- PR feat: Support setState callback in useControlledStateΒ #9041 (Oct 18, 2025) - Added "Support setState callback in useControlledState"
- This caused a regression: callbacks failed when controlled values changed externally
- PR fix: refactor useControlledState to address state-outdated issuesΒ #9331 (Dec 11, 2025) - Attempted to fix by adding forceUpdate:
// Added in 3.11.0
let [, forceUpdate] = useReducer(() => ({}), {});
let setValue = useCallback((value, ...args) => {
let newValue = typeof value === 'function' ? value(valueRef.current) : value;
if (!Object.is(valueRef.current, newValue)) {
valueRef.current = newValue;
setStateValue(newValue);
forceUpdate(); // β THIS CAUSES THE RERENDER LOOP
onChange?.(newValue, ...args);
}
}, [onChange]);Why It Causes Loops
The forceUpdate() creates a new object {} on every call via useReducer(() => ({}), {}). This:
- Forces a rerender even when state hasn't logically changed
- Combined with certain controlled component patterns, triggers infinite loops
- The discussion in the PR mentioned that "synchronization approach created infinite loops because the useControlledState parameter could change on each render"
Recommendation
Keep the override pinning @react-stately/utils to 3.10.8 until Adobe releases a fix.
π€ Expected Behavior?
Trigger rerender only on real state change or an event.
π― Current Behavior
In some scenarios this may lead to rerender loop.
π Possible Solution
No response
π¦ Context
No response
π₯οΈ Steps to Reproduce
We have a complex private app built with react-spectrum that I cannot share. Simplistic repro did not fail.
Version
3
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
macOS
π§’ Your Company/Team
No response
π· Tracking Issue
No response
Metadata
Metadata
Assignees
Labels
No labels