Skip to content

Odd behaviour with setTimeout. #9597

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
sustained opened this issue Feb 28, 2019 · 1 comment
Closed

Odd behaviour with setTimeout. #9597

sustained opened this issue Feb 28, 2019 · 1 comment

Comments

@sustained
Copy link

sustained commented Feb 28, 2019

Version

2.6.7

Reproduction link

https://jsfiddle.net/sustained/zody8sf4/

Steps to reproduce

Just look at the code/result for the test-3 component.

What is expected?

I'd personally expect test-3 to work, if test-2 and test-1 do.

And I honestly have no idea why test-5 works at all, especially if test-3 doesn't.

Something seems a bit weird here.

What is actually happening?

It doesn't.

@sirlancelot
Copy link

The created() hook is called before render() so even though the property test.foo is not reactive, it exists by the time the component is rendered except when deferred via setTimeout().

Hopefully this explains the inconsistency you're seeing. The best practice has always been to use Vue.set() or vm.$set() when creating new properties as shown in the Change Detection Caveats section of the guide.

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

3 participants