-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
issue/reviewedIssue has recently been reviewed (mid-2020)Issue has recently been reviewed (mid-2020)
Description
For filterOption, you should pass a third parameter of the option index, possibly even a fourth with the entire option array itself.
Firstly, that more akin to what is expected for filtering callbacks
But more importantly that would allow you to implement filtering optimization logic such as
filterOption={(x, search, idx) => {
if(!search) return idx < 25;
return originalFilterOption(x, search, idx)
})
In fact I would go a step further and say also pass a mutable object as the "context" of a single pass through filtering all options. Then we could do
filterOption={(x, search, idx, allOptions, ctx) => {
if(!search) return idx < 25;
if(ctx.foundCount >= 25) return false
const found = originalFilterOption(x, search, idx)
if(found)
ctx.foundCount = (ctx.foundCount || 0) + 1
return found
})
Metadata
Metadata
Assignees
Labels
issue/reviewedIssue has recently been reviewed (mid-2020)Issue has recently been reviewed (mid-2020)