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

Performance when receiving same props #124

Closed
trshafer opened this issue Sep 1, 2015 · 3 comments
Closed

Performance when receiving same props #124

trshafer opened this issue Sep 1, 2015 · 3 comments

Comments

@trshafer
Copy link
Collaborator

trshafer commented Sep 1, 2015

Hey @fmoo,

There's a significant performance issue. I have a parent component to the tokenizer which re-renders frequently. In my situation, it is improbable to change this parent component to update less frequently. My re-render is extremely fast and usually doesn't update the dom. I've tested it when I re-render my component every keydown and there is no performance slowdown with the tokenizer removed (separate input field). I believe the issue is that every time I pass the same props to the tokenizer, it calls a fuzzy match on all of my options. It happens because of this line: https://github.com/fmoo/react-typeahead/blob/master/src/typeahead/index.js#L283:L287 .

Some possible solutions:

  1. Short circuit this check when the entryValue is empty.
    • Personally, this will probably work in my use case.
  2. Have some smarter check to see if there is actually any props difference in the rerender.
  3. Make the search faster.
    • I think this is inadvisable at the current time.
  4. Other ideas?

Thanks!

@thehuey
Copy link
Contributor

thehuey commented Sep 1, 2015

Do a performance test with option 1 and see if that resolves your issue. If
so, I think that makes sense to not attempt a match on empty entry. You
could get a bit fancy and make the short circuit check a function
defaulting to empty entry.

On Tuesday, September 1, 2015, Thomas Shafer notifications@github.com
wrote:

Hey @fmoo https://github.com/fmoo,

There's a significant performance issue. I have a parent component to the
tokenizer which re-renders frequently. In my situation, it is improbable to
change this parent component to update less frequently. My re-render is
extremely fast and usually doesn't update the dom. I've tested it when I
re-render my component every keydown and there is no performance slowdown
with the tokenizer removed (separate input field). I believe the issue is
that every time I pass the same props to the tokenizer, it calls a fuzzy
match on all of my options. It happens because of this line:
https://github.com/fmoo/react-typeahead/blob/master/src/typeahead/index.js#L285
.

Some possible solutions:

  1. Short circuit this check when the entryValue is empty.
    • Personally, this will probably work in my use case.
  2. Have some smarter check to see if there is actually any props
    difference in the rerender.
  3. Make the search faster.
    • I think this is inadvisable at the current time.
  4. Other ideas?

Thanks!


Reply to this email directly or view it on GitHub
#124.

@trshafer
Copy link
Collaborator Author

trshafer commented Sep 1, 2015

This is what I've got so far: amplii@4bd61dd

@trshafer
Copy link
Collaborator Author

trshafer commented Oct 7, 2015

Issues resolved in #125.

@trshafer trshafer closed this as completed Oct 7, 2015
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

No branches or pull requests

2 participants