very bad performance when rendering array of 250elements
See original GitHub issueI am using component like this:
{{#power-select
options=countries
searchField="name"
placeholder="Click to select country"
searchPlaceholder="Type to filter..."
selectedItemComponent="country-badge/selected"
selected=billingCountry
onchange=(action (mut billingCountry))
as |country|
}}
<img src="/assets/img/country-flags/{{country.code}}.svg" class="icon-flag">
<span>{{country.name}}</span>
{{/power-select}}
When I click on it, it takes around 1second to show the list. Hovering on different countries is very slow as well. Initial rendering takes around half a second.
Do you have any ideas how can I improve performance, because 250 items should be very fast to render?
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Performance problems with long array lists in the React state
This procedure takes a long time, as React is updating the entire state again. Here I render the content: const areEqual = (nextProps,...
Read more >Fix the slow render before you fix the re-render - Kent C. Dodds
How to start optimizing your React app renders. ... Performance is a serious issue and we should make our apps as fast as...
Read more >How to useMemo and useCallback: you can ... - Developer way
The answer is simple - memoization between re-renders. If a value or a function is wrapped in one of those hooks, react will...
Read more >How to useMemo and useCallback: you can ... - DevPress
Without it, non-primitive values like arrays, objects, or functions, will be re-created from scratch on every re-render. memoization is ...
Read more >How to Detect Slow Renders in React? - Alex Sidorenko
Improving React app performance often comes down to finding bottlenecks and fixing them. One well-placed memoization can make a slow app ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Having the list in the background is better in this scenario (hundreds of options), but also much worse other scenarios.
For now the only thing I recommend is keep the number of items in a manageable size, and if it’s too big don’t display any items and allow users to type. Showing a “Loading” mesage is possible as you mention is possible tho. You have to make the options a promise
I’ll work on making the options faster, and ember itself is becoming faster at rendering
{{each}}
, but I can’t give you a time.Actually, thanks to this i’ve discovered that performance degrades when hovering over long lists. At the beginning every hover is a few ms but as i keep overing it stats to be slower and slower until it takes ~200ms.
There is some kind of leakage there. I’ll investigate it.