adobe / adobe/react-spectrum

@react-stately/utils@3.11.0 triggers rerender loop

Open
#9,420 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

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 https://github.com/adobe/react-spectrum/pull/9331 (merged December 11, 2025) introduced the rerender loop issue.

The Problem Chain

1. PR #9041 (Oct 18, 2025) - Added "Support setState callback in useControlledState"
2. This caused a regression: callbacks failed when controlled values changed externally
3. PR #9331 (Dec 11, 2025) - Attempted to fix by adding forceUpdate:
```typescript
// 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.