Skip to content

Props stability doesn't work as per docs #13157

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

Closed
sofuxro opened this issue Apr 3, 2025 · 1 comment
Closed

Props stability doesn't work as per docs #13157

sofuxro opened this issue Apr 3, 2025 · 1 comment

Comments

@sofuxro
Copy link

sofuxro commented Apr 3, 2025

Vue version

3.15.13

Link to minimal reproduction

Vue Playground - solution proposed by the docs

Steps to reproduce

Following the docs Props stability doesn't solve the issue.

Check the console to see that all items are re-rendered

What is expected?

Vue Playground - version using v-memo

Check the console to see that only the effected rows are re-rendered

What is actually happening?

It re-renders the component even though the prop value isActive stays the same. Doesn't work without v-memo

System Info

Any additional comments?

Why doesn't it work as expected (as mentioned in the docs) ? the prop value doesn't change so it shouldn't trigger the re-rendering

sofuxro added a commit to sofuxro/docs that referenced this issue Apr 3, 2025
@jh-leong
Copy link
Member

jh-leong commented Apr 4, 2025

The prop instability occurs because @click="select(item.id)" compiles to a new function on each render (onClick: $event => ($setup.select(item.id))). You can verify this in the Playground's JS output.

As a workaround, declare the emit option in ListItem to skip the event props check: Playground

@sofuxro sofuxro closed this as completed Apr 4, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants