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

[📖] Add documentation on spread operators and destructuring anti-patterns that have negative performance impacts #2432

Closed
n8sabes opened this issue Dec 14, 2022 · 2 comments

Comments

@n8sabes
Copy link
Contributor

n8sabes commented Dec 14, 2022

Suggestion

It is super common to spread properties into a component <Foo {...bar} /> as it's the obvious pattern to pass a collection of indeterminate properties. It is also super common to destructure props into a component function's arguments component$(({foo, bar}: Props) => to create cleaner looking code.

However, based on this discussion, these cause unnecessary rendering cycles.

A documentation section with these anti-patterns would be of value, and "why" it has this cost impact to help improve developer's mental model of Qwik. I use this pattern often and had no idea of the render cost until the conversation in Discord.

Also see Jermey W's Playground Example on destructuring.

@zanettin
Copy link
Contributor

Hi @n8sabes 👋
Wasn't this improved by #2545 ?

@gabrielgrant
Copy link
Contributor

gabrielgrant commented Dec 7, 2023

According to @mhevery 's demo on the office hours call today it seems like this is no longer an issue (thanks to clever optimizer tricks)

@gioboa gioboa closed this as completed Dec 9, 2023
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

No branches or pull requests

6 participants