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
Props are mutable in the template #10736
Comments
I think this may be the same problem described by #8216. |
Yes, this seems to be the same issue described in #8216. The PR from #8216 will prevent mutating props passed to child components in development mode. However, it appears to be problematic for production, as the state update will be asynchronous(parent and child states are not synced), as demonstrated in the reproduction link from #8216. Should we consider disallowing the mutation of props passed to child components in the next minor release to avoid such issues? |
Vue version
3.4.23
Link to minimal reproduction
https://play.vuejs.org/#eNp9U8tu2zAQ/JUFL5ZhQ2rRngzZ6AM5tEDboC3QQ5mDIq0dJhRJ8GE7MPzvWZKR8oDjG7kzuzO7Sx7YZ2PKbUC2YLVrrTAeHPpgVlyJ3mjr4avuDayt7mFSVvES6ZMRPlhcHx/xDABw1WrlPLQ6KA9LIErxbspVXWUJKk4Xj72RjUe6AdRJZmGWnKUszqAioK5GFpsz76juWmzKW6cVOT4kMUrojZBofxkvSJezBSQkYo2Uevc9xbwNOB/i7Q22dyfit24fY5xdWnRot8jZiPnGbpCcRfjiz0/c03kEe90FSewz4G90WoboMdO+BNWR7We85PZbGqxQm7/uYu9RuaGpaDQyj4nPGY07Tu2t1p/sfig/pjyujjTFYYcnVp7XZqw2jtbW4VoovIy34v/ETK5ohQOnD56W8k/4m4QTu5jCcpXVU4HSzGYkeH7rndimA8Q3AttGBqQODmDILaVGoL626Snkc/BeK/jUStHe0VsxJGxgBu85W/1IliD6AaFgECqUhl1jFQ10nlSy9W5aV7naWPuMzqt2X6ntKA5N26JzpPI4P7KQ+y7udSCKlDRmhOalmRRX2sM1njZWV3lGz34CV+z4AOxwP/s=
Steps to reproduce
Mutate Prop in the template(no warning, ref mutated)
buttonMutate Prop with accessing props in the script(you will see a warning, the ref will not be mutated)
buttonWhat is expected?
Both attempts to mutate the prop shows warning and block mutating
What is actually happening?
the
Mutate Prop in the template(no warning, ref mutated)
button mutates the prop without any warningsSystem Info
No response
Any additional comments?
I would like to submit two possible pull requests (PRs):
This approach addresses the issue on both branches, providing a short-term warning for the main branch while implementing a comprehensive solution for the minor branch. However, the fix for the minor branch may require additional documentation and migration efforts due to the potential breaking change.
Looking forward to the feedback from the team.
The text was updated successfully, but these errors were encountered: