Description
On main (35f2d19), ToastBarPortal calls ensureAnchorElement during rendering, appending #toastBarRoot to document.body before React commits the component.
Steps to reproduce
- Render a Suspense boundary containing ToastBarPortal followed by a sibling that suspends.
- The loading fallback is committed; the portal effect never mounts.
- An empty #toastBarRoot still remains in document.body, without the effect reference count or cleanup.
Rendering ToastBarPortal with react-dom/server in a Node environment also throws ReferenceError: document is not defined from the same render-time DOM access.
Expected: create/reference the anchor only after mounting, render no portal markup on the server, and preserve root sharing and cleanup across multiple mounted portals.
Both defects are reproduced with failing tests on main. Existing-behavior tests for child updates, shared roots, and StrictMode cleanup pass. Searches found no overlapping open PR; I am preparing an effect-owned portal lifecycle fix.
Description
On main (35f2d19), ToastBarPortal calls ensureAnchorElement during rendering, appending #toastBarRoot to document.body before React commits the component.
Steps to reproduce
Rendering ToastBarPortal with react-dom/server in a Node environment also throws ReferenceError: document is not defined from the same render-time DOM access.
Expected: create/reference the anchor only after mounting, render no portal markup on the server, and preserve root sharing and cleanup across multiple mounted portals.
Both defects are reproduced with failing tests on main. Existing-behavior tests for child updates, shared roots, and StrictMode cleanup pass. Searches found no overlapping open PR; I am preparing an effect-owned portal lifecycle fix.