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

shouldUpdate prevents every update #2118

Closed
cleytonb opened this issue Nov 29, 2016 · 2 comments
Closed

shouldUpdate prevents every update #2118

cleytonb opened this issue Nov 29, 2016 · 2 comments

Comments

@cleytonb
Copy link

Hi,

I'm trying to use the new shouldUpdate method. Unfortunately, it isn't working as I expected. Here is an example without the shouldUpdate:

https://jsfiddle.net/u0u7q2zr/2/

You'll notice that when I press any button, the child updates. But if the value don't change, I don't want the child to update. So, I tried to define shouldUpdate as follows:

https://jsfiddle.net/hn9mzxuh/1/

But that prevents the child from initializing. Am I missing something or is this a bug?

@fabien
Copy link
Contributor

fabien commented Nov 29, 2016

@cleytonb this works for me: https://jsfiddle.net/m0nnhwgz/

Note that I'm using parent.value in shouldUpdate instead, but I also need to assign this method only after mounting it seems. Which might be confusing indeed.

@cleytonb
Copy link
Author

cleytonb commented Dec 2, 2016

I found confusing that on shouldUpdate method, opts.* contains the old values and on update method, opts.* contains the new values. But since I can use the tag.* to reference the old values I believe it's ok for me.

But yes, shouldUpdate having to be assigned only after mount is confusing too.

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

No branches or pull requests

3 participants