Reputation: 2261
We are migrating to react-select v2 and when previously using the select2 JS version where "maximumSelectionLength" was available to control the elements that can be selected in Multi Select.
I could not find the corresponding option here : https://react-select.com/props
Can anyone please guide me about this.
Upvotes: 0
Views: 188
Reputation: 3098
Select2 and react-select are not affiliated with each other and therefore do not have the same APIs available.
In order to replicate the effect of maximumSelectionLength
in react-select, I would recommend using controlled props to check the value against maximum selection size so that you can remove further options from being available once the maximum is reached.
Similar to how this sandbox works https://codesandbox.io/s/x7mv9n0084
Though you will have to adapt it to your multiSelect-maxSize usecase.
Upvotes: 1