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

:key="index" => :key="JSON.stringify(suggestion)" #476

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SaulIO
Copy link
Contributor

@SaulIO SaulIO commented Oct 17, 2019

The framework needs the keys to be stable for performant rerender. Index is inherently unstable.

The framework needs the keys to be stable for performant rerender. Index is inherently unstable.
Copy link
Owner

@JosephusPaye JosephusPaye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Just one thing to consider.

@@ -59,7 +59,7 @@
ref="suggestions"

:highlighted="highlightedIndex === index"
:key="index"
:key="JSON.stringify(suggestion)"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially lead to an error if suggestion has a circular reference.

Probably not likely, but it's something to keep in mind.

Maybe we could just require a unique key property on the suggestion if it's an object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how likely there is a good use case for a circular reference within an autocomplete though?

At that level it seems more like a coding error.

Could require a key, but automating is nice. Tbf, I'd probably slice it too after stringify.

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

Successfully merging this pull request may close these issues.

None yet

2 participants