So I am working on a search bar for a website of mine, and I am having a bit of trouble with one of the components I'm using, react-select. Below is some example code
const baseOptions = [
{ label: 'Users', options:
[
]
},
{ label: 'Pages', options:
[
]
},
{ label: 'Search Google Index', value: 'search_google_index', type: "google_index" },
{ label: 'Search Bing Index', value: 'search_bing_index', disabled: 'yes' },
]
handleSearchChange = selectedOption => {
this.setState({
selectedOption,
}, () => {
console.log(`Option selected:`, this.state.selectedOption);
switch (this.state.selectedOption.type) {
case "user":
window.location = "/@" + this.state.selectedOption.label
break;
case "google_index":
console.log("Searching google index");
/*Here is where I need to catch the value of react-select*/
break;
default:
break;
}
});
};
The issue
I am not sure how to fetch the value of what is typed into the box before the new value is selected.
The Goal
I am aiming to search google for the term typed into the field when a user selects "Search Google Index"