React-select: Add maxOptions prop

Created on 3 Oct 2018  路  4Comments  路  Source: JedWatson/react-select

Prop to restrict the number of results

We need a way to restrict the number of results rendered on the Select/Async select components.

Use case

This is extremely useful if the number of options is too high and if someone wants to limit the items being displayed to improve performance.

API

Add maxOptions optional prop for Select/AsyncSelect which takes a number.

issuenhancement issuhas-pr issureviewed

Most helpful comment

Hi @Chopinsky @nithinpeter

I needed this too, so I pushed this : https://github.com/JedWatson/react-select/pull/3229

Actually, I need it on a non-async select because sometimes I have > 10 000 options, and for performance reason I want to limit the number of shown options, and let the user type to find more ...

All 4 comments

I think the follow up question would be how to determine what options shall be filtered? I think you may be asking for the incremental loading of the options.

Not really! Say for example you have an AsyncSelect component, and your search returns 10,000 results. You need a mechanism to restrict the number of items rendered for performance reasons.

It may not make a lot of sense for Select, but I think it is useful to have this prop available for AsyncSelect.

Hi @Chopinsky @nithinpeter

I needed this too, so I pushed this : https://github.com/JedWatson/react-select/pull/3229

Actually, I need it on a non-async select because sometimes I have > 10 000 options, and for performance reason I want to limit the number of shown options, and let the user type to find more ...

Is this gonna be added any time soon?

Was this page helpful?
0 / 5 - 0 ratings