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

Data read in watch being treated as a rendering dependency #2521

Closed
skirtles-code opened this issue Oct 29, 2020 · 0 comments · Fixed by #2524
Closed

Data read in watch being treated as a rendering dependency #2521

skirtles-code opened this issue Oct 29, 2020 · 0 comments · Fixed by #2524
Labels
has PR A pull request has already been submitted to solve the issue 🐞 bug Something isn't working

Comments

@skirtles-code
Copy link
Contributor

skirtles-code commented Oct 29, 2020

Version

3.0.2

Reproduction link

https://jsfiddle.net/skirtle/jd9mnzu2/

Steps to reproduce

  1. Click 'Button 1'. Note the logging. The root component has updated unnecessarily. If you click 'Button 1' again nothing will happen.
  2. Click 'Button 2'. Both the root and child components will update. That is expected.
  3. Click 'Button 1' again. This time the child component updates unnecessarily.

What is expected?

Clicking 'Button 1' updates the count property. That shouldn't trigger any rendering.

What is actually happening?

Extra rendering is occurring, first in the parent component and then in the child.


The key to this is the watch. If you comment out the contents of the handler it all works as expected with 'Button 1' not triggering any rendering.

The first problem is caused by the immediate: true. It seems that any reactive data read during that initial call is treated as a rendering dependency of the parent component. Presumably because the parent component is still considered to be rendering at that point.

The second problem is similar. The watcher is triggered by the prop change and the dependency seems to be registered against the rendering of the child.

Update:

The first problem can also be triggered using a created hook instead of an immediate watcher. See https://jsfiddle.net/skirtle/jd9mnzu2/1/ to reproduce that variant of the problem.

@LinusBorg LinusBorg added the 🐞 bug Something isn't working label Oct 31, 2020
@posva posva added the has PR A pull request has already been submitted to solve the issue label Nov 18, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has PR A pull request has already been submitted to solve the issue 🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants