-
Notifications
You must be signed in to change notification settings - Fork 49k
Open
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
React version: 19.1.0
Steps To Reproduce
- Go to the example project.
- Tweak the compute iterations (simulating a slow render function) to a sufficiently large number.
Link to code example: https://stackblitz.com/edit/react-mwegmaqm?file=App.jsx
Reproduced here:
import React, { useState, useEffect, use } from 'react';
const LOADING_UPDATE_INTERVAL = 10;
// Setting this value to a large number such that slowCompute() takes longer than the LOADING_UPDATE_INTERVAL means that the suspense will always show the fallback.
const DELAY_ITERS = 200_000;
function slowCompute() {
for (let i = 0; i < DELAY_ITERS; i++) crypto.randomUUID();
}
// A loading fallback that updates itself, for example to display some cute loading messages.
function Loading() {
const [count, setCount] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setCount((prev) => prev + 1);
}, LOADING_UPDATE_INTERVAL);
return () => clearInterval(interval);
}, []);
return <>Waiting for {count} </>;
}
// The child that renders slowly, in practice this might be a large data table.
function SlowThing(props) {
const v = use(props.promise);
slowCompute();
return <>Loaded</>;
}
const App = () => {
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('yay');
}, 100);
});
return (
<React.Suspense fallback={<Loading />}>
<SlowThing promise={promise} />
</React.Suspense>
);
};
export default App;
The current behavior
The fallback will be displayed indefinitely, while the actual component rerender gets triggered over and over again.
The expected behavior
The actual component is displayed eventually.
polarcoconut, vikasyadavvvv and himself65vikasyadavvvv and ChinmayBhattt
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug