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

KeepAlive does not work with a child whose key = NaN #1513

Closed
danyadev opened this issue Jul 5, 2020 · 3 comments
Closed

KeepAlive does not work with a child whose key = NaN #1513

danyadev opened this issue Jul 5, 2020 · 3 comments

Comments

@danyadev
Copy link

danyadev commented Jul 5, 2020

Version

3.0.0-beta.18

Reproduction link

https://jsfiddle.net/danyadev/d73m9qek/

Steps to reproduce

Click on the button and look at the console

What is expected?

no errors

What is actually happening?

TypeError: parentComponent.ctx.deactivate is not a function
    at unmount (vue.global.js:8623)
    at patch (vue.global.js:7711)
    at Object.sharedContext.activate (vue.global.js:9216)
    at processComponent (vue.global.js:8081)
    at patch (vue.global.js:7742)
    at componentEffect (vue.global.js:8268)
    at Object.reactiveEffect [as update] (vue.global.js:4181)
    at updateComponent (vue.global.js:8157)
    at processComponent (vue.global.js:8088)
    at patch (vue.global.js:7742)

If the Foo component is added with a deactivated hook, then it will work on the first click, but the error will not disappear

@yyx990803
Copy link
Member

NaN === NaN // false

Make sure to never use NaN as a key.

@danyadev
Copy link
Author

danyadev commented Jul 6, 2020

I understand that this is a bad use case for key. Nevertheless, it was used in my code, although I did not even know about it, and everything worked perfectly.

@yyx990803
Copy link
Member

This is a wontfix - key by definition must be identity unique and NaN is not a valid key. I added a warning for it in da40ff49.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants