Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
commit: |
There was a problem hiding this comment.
Pull request overview
This PR adds a failing test case to reproduce issue #1937 related to createPortal behavior during popstate navigation. The test verifies that rapid back/forward navigation with portal-rendered content doesn't corrupt the browser history or produce runtime errors.
Changes:
- Adds new test case that simulates back/forward/back navigation churn with delayed portal route requests
- Adds a new link in the start page to navigate to a portal-enabled route
- Updates the RouteState component to conditionally render a portal marker based on query parameter
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| e2e/router-client.spec.ts | Adds test case for portal route with popstate navigation that verifies no runtime errors occur and query history is preserved |
| e2e/fixtures/router-client/src/pages/start.tsx | Adds link to navigate to portal-enabled route (/next?portal=1) |
| e2e/fixtures/router-client/src/components/route-state.tsx | Implements conditional portal rendering based on 'portal' query parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {portal && | ||
| createPortal( | ||
| <div data-testid="portal-marker">portal</div>, | ||
| document.body, | ||
| )} |
There was a problem hiding this comment.
The portal is created on every render without checking if document.body is available. In SSR contexts or during hydration, document.body may not be defined, which will cause a runtime error. Add a guard to ensure this only runs on the client side, such as checking if typeof document !== 'undefined' before calling createPortal.
|
I don't think it's a reproduction. |
for #1937