-
Notifications
You must be signed in to change notification settings - Fork 23
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
Navigate using render #374
Conversation
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
41a0b7b
to
cef76d5
Compare
571236c
to
e4f002b
Compare
c85f665
to
43718c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
60% LGTM
35% TYP
5% Comments to think about
const { | ||
[page]: { allowConditions, declarer }, | ||
} = pagesState | ||
const shouldSkipFetchNavigationData = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a huge improvement when navigating to pages already cached and that don't have conditional content (basically only store routes were declaring allowConditions: true
) 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that and added it back
react/utils/routes.ts
Outdated
__pickRuntime: runtimeFields, | ||
}) | ||
const url = `${path}?${query}` | ||
const page: ServerPageResponse = await fetch(url, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better set credentials
to same-origin
to ensure we will send cookies.
Also, be careful because fetch will not throw any errors when receiving 4xx or 5xx status code. We should do something like render-session did here.
Another thing to think: fetch will follow redirects by default and we can't do that, we need to handle those redirects by our own to change history and navigate to the redirected page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added render-session code and set credentials to same-origin
. However, I could not make the redirects work. I read some of the discussion in this thread and it seems there is no way of handling redirects in JavaScript code when using fetch
Your PR has been merged! App is being published. 🚀 |
All right, so this is a fun one. This PR entirely rewrites (punch intended) the routing of the web framework, so no need to panic here.
The main ideia behind this PR is to remove all routing related code from runtime and use
__pickRuntime
from render-server for having a single source of truth for the navigation/rendering.This is VEEEERY dangerous and should be testes carefully by everyone. Also, releasing the app will increase the traffic both in render and in rewriter, so they need to be scaled up a little bit