shouldUpdate prevents every update #2118

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

Comments

Projects
None yet
3 participants
@cleytonb

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

This comment has been minimized.

Show comment
Hide comment
@fabien

fabien Nov 29, 2016

Contributor

@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.

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

This comment has been minimized.

Show comment
Hide comment
@cleytonb

cleytonb 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.

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