I followed a tutorial to use react-select dropdown in my react js , typscript project. I was able to work with the code below, but I am new to react js and typescript. how do i get the value of the selected in the code below. say, in the selectHandler function , i want to compare selected value as such
`
if ( this.state.someValue == 'b")
`
I get an error because, this.state.someValue is not a string . how to extract the just the value after user selects it.
import * as React from "react";
import Select, {ValueType} from 'react-select';
interface SomeState { someValue: ValueType<{ value: string; label: string; }>; }
const opt = [{ value: 'a', label: 'awesome' }, { value: 'b', label: 'boring' }];
export class someClass extends React.Component<any, SomeState> {
constructor(props: any) {
super(props);
this.state = { someValue: null}
}
public render(): JSX.Element {
return ( <>
<Select value={this.state.someValue} onChange={this.selectHandler} options={opt} />
</> );}
private selectHandler (selectedFromPlace: ValueType<{ value: string; label: string; }>):
void {
this.setState({ someValue});
};
}`