-
Notifications
You must be signed in to change notification settings - Fork 47.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: setState is not flushed if an iframe is added in the same tick in Safari #24458
Comments
I suspect this might be #22459 (comment) showing its head again. Can you check the issue repros in desktop Safari as well? |
Yes, same on Safari Desktop. Will update issue description. €: Also reproduceable with |
Minimal repro. function App() {
const [count, setCount] = React.useState(0);
return (
<button onClick={() => {
setCount(c => c + 1);
document.body.appendChild(document.createElement("iframe"));
}}>
{count}
</button>
);
};
const rootElement = document.getElementById("app");
const root = ReactDOM.createRoot(rootElement);
root.render(<App />); Only repros in Safari and only when served over http(s). |
Batched state changes are not flushed if the promise code changes the DOM (= attaching an iframe). Reproduceable with Safari.
React version: 18.1.0
Steps To Reproduce
Link to code example:
https://codepen.io/kh-viewar/pen/wvpVLxM
The current behavior
State changes are not executed.
The expected behavior
State should change to true and render spinner component. After promise is resolved (2 seconds timeout), state should switch back to false and spinner component should unmount.
Original discussion
#24365
The text was updated successfully, but these errors were encountered: