qwik icon indicating copy to clipboard operation
qwik copied to clipboard

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

Open n8sabes opened this issue 2 years ago • 1 comments

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.

n8sabes avatar Dec 14 '22 07:12 n8sabes

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

zanettin avatar Jan 12 '23 20:01 zanettin

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)

gabrielgrant avatar Dec 07 '23 19:12 gabrielgrant