qwik
qwik copied to clipboard
[✨] Keyed Fragments
Is your feature request related to a problem?
When rendering multiple children inside an Array.map and a wrapper element is undesirable, there seems to be no way to specify a key.
React, in comparison allows putting the key on a Fragment.
https://reactjs.org/docs/fragments.html#keyed-fragments
Quik also has a Fragment component, but it does not have a key prop.
Describe the solution you'd like
Add a key prop to Fragment.
{items.map(item => (
<Fragment key={item.id}>
<div>{item.foo}</div>
<div>{item.bar}</div>
</Fragment>
)}
Describe alternatives you've considered
- Using a wrapper element, but sometimes this is undesirable.
- Putting the key on the first child of the fragment (item.foo in the example above) seems to avoid errors, but I'm not sure if that's a false-negative on the tooling side and whether it actually works as intended.