-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[🐞] Spread Operator in Qwik Does Not Trigger Reactive Updates for Props #7397
Comments
Should be fixed in v2: Please note that version 2 is in alpha phase |
Thank you @Varixo Could you please help me understand how this issue was fixed? Also, is there an alternative approach we could consider? Since |
@yash-builder I believe that the fix was that the v2 optimizer handles spread props way better now. |
As Wout said, this works in v2 because of fixes in the optimizer. |
Which component is affected?
Qwik React
Describe the bug
In Qwik, when spreading an object
({...state.helloProps}
) into a component's props, the UI does not update when the object properties change. The workaround requires forcing updates by using a uniquekey
(e.g.,JSON.stringify(state.helloProps)
) to ensure the component re-renders.This issue occurs because Qwik does not track object property changes inside the spread operator unless the reference itself changes.
Reproduction
https://qwik.dev/examples/introduction/hello-world/#f=7VZNS8NAEL33VwxFaAJhpRU8rEm9ePKgB%2F9AJZtKaLHiFwnL%2FnffzG7SJo3FSwTBU0OTTd6beTPvHYpmcTGomqT13JP6mXimHmzW0U9ICpbWu921bqKAO5IVJ4ElnsFOopwXLs7IWYU%2FXXou9yG1yaTtqcG2eo8qtLFj9xWfiK%2BaN1fkfibwkEjEDLKWd2ThWKCF4RMeDgvtiE1CNzWWbpm35qJDMRjwniTHKN8GvvJssR00pfIrI5FNeainvGM%2BEEYEj9pDkHIgd0jMOctsVHwmVGyFRTT0MLgUWyVvix1E4cNci6IJPZawP9FWTbP5S0WoZmkICzvfzBL4jTEgqmm%2BSJAwXp%2FKZ02X5NySgsZC52BMQn4Y9jiffoMzPhpKfcGtUqr%2FcaYd1D8igEj0WJj4EIrXaB%2BQNGJERJJJVpuiXtHtw%2F0dCsI6Ldf16SrhQGa7B34dOiYVGQI5jocfg%2BHxQj3fjUIfjb%2F4d6W%2F6kpf
Steps to reproduce
state.helloProps.foo
.Hello
receives props:spread
case does not update.spread (deopted)
case works because of explicit access to the object.with key JSON.stringify
case works because it forces re-render.explicit prop
case works correctly.System Info
Additional Information
Expected Behavior:
When spreading
state.helloProps
into<Hello {...state.helloProps} />
, the component should update as soon asstate.helloProps.foo
changes.The text was updated successfully, but these errors were encountered: