-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fixed component rerendering if there's only one renderer (solid-js) #12131
base: main
Are you sure you want to change the base?
Fixed component rerendering if there's only one renderer (solid-js) #12131
Conversation
|
993f55b
to
d9fba90
Compare
// If there's only one renderer in the project (solid-js) | ||
// we can skip the `check` calls and use that renderer (to not render solid component twice) | ||
if (renderers.length === 1 && renderers[0].name === '@astrojs/solid') { | ||
renderer = renderers[0]; | ||
} else { |
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 is the only change
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.
oops, accidentally approved.
break; | ||
// If there's only one renderer in the project (solid-js) | ||
// we can skip the `check` calls and use that renderer (to not render solid component twice) | ||
if (renderers.length === 1 && renderers[0].name === '@astrojs/solid') { |
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.
Why only Solid.js?
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.
because for some reason the tests fail for other frameworks. Moreover for solid it's critical to be rendered once, because solid doesn't have this "rerender" paradigm as react, preact or others.
More common solution could require much more efforts, so it should be carefully implemented. This is really easy fix which can help many people (because solid-start it's not that production-ready yet, so many people use astro+solid to get SSR), so we can do improvements step by step.
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 tried to apply the solution suggested here, but looks like it doesn't work anymore for all the frameworks.
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.
What tests fail? It's likely something we can fix. I don't think we should special-case one particular renderer in this case. There's nothing about this suggestion that shouldn't work everywhere.
If you could post the errors that occur when this is enabled for all renderers that would be helpful.
Changes
In this PR multiple server rerendering of the solid component is skipped if there's only one renderer in the project (solid-js).
I used only part of the solution for this issue.
If there're multiple rerenders, it should be processed in another way I suppose, but this little change can help if there's only one solid-js renderer.
Testing
Test was also added.
Docs
No need to update docs