-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
React-select is slow when you have more than 1000 items #3128
Comments
Two things to look into that may help with your issues, we also had some issues regarding large lists. filterOption={createFilter({ignoreAccents: false})} Take a look at this reported bug #2850 There's two examples using React-Window, which greatly improves the performance. |
@M1K3Yio I suppose, that the main issue is |
Duplicate of #2711 |
I have a quick work around fix: Pass your own MenuList component, iterate through the childs and remove this props below. It stops lagging then. But you need to add styles for hover via css then. delete key.props.innerProps.onMouseMove; |
@endbay It worked for me. Thanks! const { onMouseMove, onMouseOver, ...newInnerProps } = props.innerProps |
I am running into the same issue. I have only about 300 items in the list. Looking at the code, removing the onMouseOver and onMouseMove will cause some functionality to not work. Will this be fixed anytime soon? Anand |
Could you show the code? |
const MenuList = function MenuList(props) {
const children = props.children;
if (!children.length) {
return (<div className="myClassListName">{children}</div>);
}
return (
<div className="myClassListName">
{children.length && children.map((key, i) => {
delete key.props.innerProps.onMouseMove; //FIX LAG!!
delete key.props.innerProps.onMouseOver; //FIX LAG!!
return (
<div className="myClassItemName" key={i}>{key}</div>
);
})}
</div>
);
}; <Select
components={{
MenuList
}}
/> Probably not the best approach. But it's working for me. If anyone has suggestions for improvement, I would be grateful. |
@shunfan solution (object destructuring) is cleaner to me |
Can someone post a full code sample of the solution that @shunfan proposed? |
const Option = ({ children, ...props }) => {
const { onMouseMove, onMouseOver, ...rest } = props.innerProps;
const newProps = Object.assign(props, { innerProps: rest });
return (
<components.Option
{...newProps}
>
{children}
</components.Option>
);
}; Example of @shunfan solution |
It is insane that ignoreAccents' default is set to true! Setting this to false, in my case where I'm pairing react-select with react-virtualized, resulted in huge perforance boosts, with very little lag if any. Been looking for this solution for a long time. Thanks @endbay ! |
Seems to only be a workaround. |
The performance penalty for filter each option in a quite large set of data is insanely slow on force reconciliation a new
In my case, I am dealing with a set of 2000 items and I do not need to filter, so I disable the whole thing, the speed bost quite a lot, check the time just the filter method takes. Furthermore, following the recommendation of #2850 I'm using
I hope that helps, this is still a workaround, but it works for me pretty well. |
There is no interest of autocomplete without filtering the options. It's just a simple select otherwise. |
If it's the typing lag that you're bumping on (I was) then it's actually the Using this massively reduces the lag when you're typing into the select. I've got a sandbox here that illustrates: https://codesandbox.io/s/zn70lqp31m?fontsize=14 |
Removing the mouse events from Option and providing your own hover styling via CSS improves performance considerably, but it means the Even a list with relatively few items is very slow with the mouse events enabled, I have a list with <100 items and running my mouse up and down the list is super laggy. I'm not sure what the solution could be here, removing styling for
But there are definitely more props than just those changing as subsequent focus changes after the first one don't cause any elements to re-render. |
This did the trick. Thanks man |
Two more hints that may help someone (I hope), that helped me after struggling with even react-modal-solution being a bit laggy. Deadly lags appeared while hovering and "mouseovering" the dropdown elements, with even "poor" 250 options. So hints that may help:
|
Facing slowness too for only 250 items making the widget a no-go for us in production. I'm on version |
@nadzimo The ignore accents help a ton, idk if you've done that already, but I have about that many items if not more in my dropdown. Also using the custom made MenuList item with react-virtualized. I didn't use the specific one in this thread, but another shorter one in another github forum/question. Let me know if you need help finding it. |
@willbee28, I wasn't familiar with react-virtualized and just checked it out – looks slick. Will give it a go. |
I recommend using it with the MenuList component, utilizing the List
component from react-virtualized.
…On Wed, Jul 31, 2019, 4:50 PM nadzimo ***@***.***> wrote:
@willbee28 <https://github.com/willbee28>, I wasn't familiar with
react-virtualized and just checked it out – looks slick. Will give it a go.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3128?email_source=notifications&email_token=AGI42AODEKOSVLTCIX2EHI3QCH3JRA5CNFSM4F6BPYAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3IQR4Q#issuecomment-517015794>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGI42APFLDEWOZI5LTMHBDDQCH3JRANCNFSM4F6BPYAA>
.
|
If you guys are using pretty old version like in my case 1.2.0 directly pass |
What issues specifically, is this a render delay? I believe we're seeing an issue in a large form where potentially hundreds of selects can create a poor UX due to render delay. If this is related, is there an existing issue? I may want to contribute if I can navigate the emotion spaghetti and ripples it'll cause. |
Works perfectly!
or like this: (tailwind itc)
|
Hi @VladimirMilenko, In an effort to sustain the react-select project going forward, we're cleaning up and closing old issues and pull requests. We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our efforts towards the current major version. If you aren't using the latest version of react-select please consider upgrading to see if it resolves any issues you're having. However, if you feel this issue is still relevant and you'd like us to review it - please leave a comment and we'll do our best to get back to you! |
I have 50,000 items in my Select from react-select. I tried many things to improve performance: set ignoreAccents to false, disable onMouseMove and onMouseOver events and virtualization. But it's still slow. Taking up @lynxtaa 's idea, I found the react-select-async-paginate library which allows you to "paginate" the items, and to retrieve the ones you want with the search. The library : https://www.npmjs.com/package/react-select-async-paginate |
I have just 1000 items, it's already very laggish. |
i love how this thread is still going after all this time. just ask GPTChat to write your implementation. Or paste (a simplified version) of your implementation into GPTChat and ask it to correct. Tell it what's wrong. Show it where it hurts. It will help you. 🤖🤖🤖 |
Yeah, well, I was brought here in search of a built-in option for virtualization, honestly, I believe that a library that handles select dropdowns should have that option built-in. The fact that this is still going since 2018 should already tell everyone that there's real demand for it. But since react-select seems to not be bothered by it, I just followed the |
The entitlement of kids these days. |
Such a judgemental state of mind. |
I'm pretty sure this project is accepting PRs |
There's a PR addressing the performance on large lists. The solution followed the memoization of buildCategorizedOptions rather than virtualization. |
If you're referring to #5450, virtualization and disabling stripping diacritics have a much bigger impact on performance for large lists. That PR just makes it even faster assuming you're already doing those performance improvements. |
We’ve updated the tool from v2.x to v5.x last week and the performance issues are still there. I wanted to let you know. i’ve seen couple of workarounds and tips how to improve the performance, we are going to look into them next week and will let you guys know our findings. Edit: |
if i am using the filterOption for custom logic, then how can i set ignoreAccents:
|
Same problem. Did you find a solution? |
@timjahn93 did not find a solution to filter option issue but, what i found was react select was very slow when the developer tools was open in chrome. Also, if there is huge data, better use virtualization with react window. Also check your extensions. |
@vikrant-gembrill Okay, I am using virtualization already, but using my own filter option, react select is too slow with high data and the page collapses. With createFilter and ignoreAccents it is way more performant. |
Just as a reference for anyone else who might encounter this problem, the solution using filterOption works like magic: |
Here's another working example too for anyone who winds up here. Feel free to star the gist if it helps you |
Low performance on large sets of options
React-select slows down when you have a huge array of data. Mouse
![screenshot 2018-10-19 at 15 29 43](https://user-images.githubusercontent.com/18203255/47221169-00745c80-d3b4-11e8-80d9-7e7c035823c1.png)
![screenshot 2018-10-19 at 15 51 21](https://user-images.githubusercontent.com/18203255/47222437-09b2f880-d3b7-11e8-927a-b7c8215d4f7f.png)
FPS drops so low on mouseover, that i can barely use it.
In my real case, where i have 1010 items, which i need to show(and i can't load them as user types) - i cannot do anything at all.
You can find a simple example in codesandbox.
https://codesandbox.io/s/q8l6xnvz7w
React-select version: 2.1.0
The text was updated successfully, but these errors were encountered: