Skip to content
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

feat: support view transitions #1207

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

pmelab
Copy link
Contributor

@pmelab pmelab commented Feb 3, 2025

Adjust the client side router to use startViewTransition if available and provide and example.

  • Link navigation
  • Programmatic navigation
  • Browser prev/next buttons

Does not work in Firefox, since it does not support that API yet.
Also there is no automated test since I really have no idea how to test that.

Copy link

vercel bot commented Feb 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
waku ✅ Ready (Inspect) Visit Preview Feb 4, 2025 5:07pm

Copy link

codesandbox-ci bot commented Feb 3, 2025

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.

});
};

if ('startViewTransition' in document && !skipRefetch) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need skipRefetch here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took over conditions to not start the transition if it wouldn't change anything, but that's completely wrong here.

@pmelab
Copy link
Contributor Author

pmelab commented Feb 4, 2025

I'm struggling to resolve the one remaining issue:

When clicking a broken link, we fall back to loading the RSC payload for 404 pages here:

return fetchRsc(encodeRoutePath('/404'));

I stepped through the debugger. The 404 data is there, and for the remaining process it should be the same as a regular route change. But for some reason we eventually end up here:

throw new Error('Invalid element: ' + id);

@pmelab
Copy link
Contributor Author

pmelab commented Feb 4, 2025

More findings:

It seems like react rendering continues while startViewTransition is in progress and renders the non-existent page a second time. And thats where the error happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants