Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing the `No data found` validation message in react-select

The default message shown by react-select when there is no data found while typing is No option. Is it possible to customize this message?

like image 380
Prem Avatar asked Dec 07 '18 03:12

Prem


People also ask

How do you change no options in react select?

You can define your own NoOptionMessage component: import { components } from 'react-select'; const NoOptionsMessage = props => { return ( <components.

How do I change the default option in react select?

You can use an attribute defaultValue to set the default value in the Select menu If none option is integrated with this attribute first option is selected by default. You can create an Array of the object where you will store all options to be displayed and any single object is passed in the defaultValue attribute.


1 Answers

You can use noOptionsMessage prop like this:

<Select options={options} noOptionsMessage={() => 'FOOOO!'}/>

You can see it working here

like image 81
Akrion Avatar answered Oct 15 '22 14:10

Akrion