-
Notifications
You must be signed in to change notification settings - Fork 616
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
If Fresh /components/ folder doesn't return JS, should I even bother with memo()? #2433
Comments
In 99% of cases you don't need With Fresh's islands architecture this is even more rare as most components are only rendered once on the server. This makes The only scenario where it could theoretically matter (in 99% of cases it doesn't) is with islands or components that are rendered inside islands. But again, this is very rare. |
yes, that's what i assumed. But what about inside islands where there are changing data that's passed down to stateless /components/ ? For example:
These 2 are good use cases where components need to re-render frequently. And I don't think these are rare cases, these are very common in every app. In these 2 examples, should I only use memo() inside /islands/ ? What about /components/ that are re-rendered frequently due to data changes in /islands/ ? For example, if I have an infinite scroll list, and the list contains 1000 items. Those 1000 list items will be written in /components/, if the list data changes in /islands/ will that cause the 1000 item to re-render? Will it re-render 1000 more times every time the list gets appended? What do I do then? Or how about a chat app? Same related problem there. So what's the proposed solution in this case? Should I...
Thank you. Please advise best practice. |
The |
I see, so your proposed solution is don't use memo() and rely on signals. |
I understand that everything in /components/ are basically html and only served as such to the client without any javascript.
If that's the case, should I even bother wrapping the functions into a memo(..) in any files in the /components/ folder?
If islands' javascript code works, then that means data will change and pass down to components in /components/ files. But if they are html, and not javascript, does it matter?
Should all /components/ be written in pure functions? Should memo() ever be used except islands?
Please advise.
The text was updated successfully, but these errors were encountered: