React-select: [Question] Triggering a callback when there are no results

Created on 24 Jun 2017  路  4Comments  路  Source: JedWatson/react-select

I was wondering if there was work around to triggering a callback where there are no options based on the value?

<Select
            ref="stateSelect"
            name="selected-state"
            placeholder="Select State"
            autofocus
            simpleValue
            clearable
            searchable
            value={this.state.selectedState}
            options={this.state.options}
            onChange={this.onChange}
            onNoResult={this.onNoResults}
/>

I was thinking of using optionRenderer, but this doesn't trigger when there are no options.

BTW, great work!

categorquestion

All 4 comments

Hi @kevinrogerteng whats the use case for the no result callback? We do show text but it sounds like you need more than that.

@agirton Thanks for the reply! The use case is quite similar to Async Creatable where rather than having the button/function to create within the <options /> I would have a button shown externally instead.

screen shot 2017-06-26 at 9 25 54 am

It's a really tiny use case and personally, just a nice to have.

Hi @kevinrogerteng I see. Thank you for the use case! In most cases users can obtain when there are no options available it may be confusing on when to use this callback.

The Creatable just wraps the Select component, it seems like this could be built on the user side.

@agirton Yeah, that makes sense! I'll look into Creatable a bit more. It was just an out of the blue question. Thank you though!

Was this page helpful?
0 / 5 - 0 ratings