Skip to content

Warn about modifying instance in hooks #723

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

Merged
merged 2 commits into from
Jan 26, 2017

Conversation

bmacnaughton
Copy link
Contributor

@bmacnaughton bmacnaughton commented Jan 21, 2017

I ended up spending a fair amount of time tracking down unpredictable behavior as a result of doing exactly that. I wrote components to display the "updated" count as I implemented the various parts of the guide for visual feedback on how often updates were taking place. I then wrote a component to do so and found that it worked when written certain ways but not in others, and yielded unpredictable results. I tried tracking them down.

I had thought about the circular reference/infinite loop but presumed that Vue had detection logic and broke the chain when it detected the looping (and it seemed to). So I was trying to figure out what I didn't understand about components when one didn't work as I expected. See https://stackoverflow.com/questions/41780872/vue-js-component-updates-inconsistently for details if interested.

It might make more sense not to introduce instance lifecycle events this early in the guide, but that's more major change.

bmacnaughton and others added 2 commits January 21, 2017 14:48
I ended up spending a fair amount of time tracking down unpredictable behavior as a result of doing exactly that. I ended up writing components to display the "updated" count just for visual feedback on how often updates were taking place. I then wrote a component to do so and found that it worked when written certain ways but not in others, and yielded unpredictable results. I tried tracking them down.

I had thought about the circular reference/infinite loop but presumed that Vue had detection logic and broke the chain when it detected the looping (and it seemed to). So I was trying to figure out what I didn't understand about components when one didn't work as I expected. See https://stackoverflow.com/questions/41780872/vue-js-component-updates-inconsistently for details if interested.

It might make more sense not to introduce instance lifecycle events this early in the guide, but that's more major change.
@chrisvfritz
Copy link
Contributor

I removed the warning, but added some links to the API for people who immediately want to go deeper. Since this page is just to give a very broad overview of how Vue works and explicitly states that people are not meant to understand it all yet, I want to avoid specific usage recommendations.

@chrisvfritz chrisvfritz merged commit 33b9f12 into vuejs:master Jan 26, 2017
@bmacnaughton bmacnaughton deleted the patch-1 branch January 27, 2017 15:26
dingyiming added a commit to volksbright/document-standard-vue that referenced this pull request Jan 29, 2017
* vuejs.org-master:
  update instructions about where to open the javascript console
  Fix bug in store pattern example (vuejs#732)
  add cache option deprecated section (vuejs#731)
  Warn about modifying instance in hooks (vuejs#723)
  Revert "`cache` option for computed properties." (vuejs#728)
  update updated lifecycle hook description
  fix fuzzy matching when match already exists
  Update smooth-scroll.js (vuejs#726)

# Conflicts:
#	src/v2/api/index.md
#	src/v2/guide/index.md
#	src/v2/guide/instance.md
#	src/v2/guide/migration.md
#	themes/vue/source/js/common.js
#	themes/vue/source/js/smooth-scroll.min.js
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

Successfully merging this pull request may close these issues.

2 participants