Skip to content
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

When JSX is used, v-slots cause child component does unnecessary rendering during parent component re-rendering #712

Open
yuwu9145 opened this issue May 31, 2024 · 10 comments

Comments

@yuwu9145
Copy link

Vue version

3.4.21

Link to minimal reproduction

https://github.com/yuwu9145/vue-jsx-slot-demo

Steps to reproduce

  1. Load and run the project
  2. Type something in the input to trigger parent App component render function
  3. Check console logs
  4. Then go to src/App.tsx and comment out line 20
  5. Type something again
  6. Check console logs again, see the different results

What is expected?

Only parent App component's onUpdated hook should be triggered, child Test component should not be re-rendered as nothing is changed to trigger child Test render function

What is actually happening?

Both parent App and child Test components are re-rendered

System Info

System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 114.45 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
    Yarn: 1.19.0 - ~/.nvm/versions/node/v18.19.0/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
  Browsers:
    Chrome: 125.0.6422.141
    Firefox: 124.0.2
    Safari: 17.2.1
  npmPackages:
    vue: ^3.4.27 => 3.4.21

Any additional comments?

No response

@yuwu9145 yuwu9145 changed the title When JSX is used, v-slots cause child component does unnecessary rendering when parent component does re-rendering When JSX is used, v-slots cause child component does unnecessary rendering during parent component re-rendering May 31, 2024
@yyx990803 yyx990803 transferred this issue from vuejs/core May 31, 2024
@uke5tar
Copy link

uke5tar commented Jun 12, 2024

Hi folks,
Is there an expected timeline for resolving this issue? I am waiting eagerly for a fix here because it affects the linked rendering of VTreeview in Vuetify quite significantly. No intend to pressure - just curious as it would affect my planning in a work-around. Thank you!

@TheInvoker
Copy link

+1 same for me, same boat

@angrymarker
Copy link

this is the last item I need updated to convert my project from vue2 to vue3, would love an ETA

@Zheng-Changfu
Copy link

Is there an expected repair time? I think this has a great impact on performance

@Zheng-Changfu
Copy link

Setting $stable to true in v-slots prevents updates for subcomponents,I'm looking at this issue:#525

@Zheng-Changfu
Copy link

v-slots={{
$stable:true
}}

@yuwu9145
Copy link
Author

yuwu9145 commented Aug 9, 2024

$stable:true resolves our performance issue, what's the official way of using it?

@Zheng-Changfu
Copy link

$stable:true解决了我们的性能问题,官方的使用方法是什么?

jsx 目前没有做这种编译处理, vue slot 有3种类型,stable、dynamic、forward,template 语法会在编译过程中根据上下文自动编译出插槽类型,从而在更新判断中做优化处理,而 jsx 没有做这种处理,所以会强制更新

vue 更新判断源码
vue slot types
vue 目前没办法做到插槽的依赖收集

@Zheng-Changfu
Copy link

$stable:true解决了我们的性能问题,官方的使用方法是什么?

jsx 目前没有做这种编译处理, vue slot 有3种类型,stable、dynamic、forward,template 语法会在编译过程中根据上下文自动编译出插槽类型,从而在更新判断中做优化处理,而 jsx 没有做这种处理,所以会强制更新

vue 更新判断源码 vue slot types vue 目前没办法做到插槽的依赖收集

stable 才会在更新过程中做优化,dynamic 会强制更新,forward 会根据运行时的行为决定

@mxcabre
Copy link

mxcabre commented Sep 17, 2024

Any updates ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants