Trying to change state on Change using a React Select node module package, if its a regular text input it works but can't quite get this to work, returns "TypeError: event.target is undefined".
Only putting in the code that matters, not full page.
class App extends Component {
constructor(props) {
super(props);
this.state = {
value: "15",
options: [
{ label: "Sup", value: "18" },
{ label: "Sup", value: "18" },
{ label: "Sup", value: "18" },
{ label: "Sup", value: "18" }
]
};
this.stateChange = this.stateChange.bind(this);
}
stateChange = event => {
console.log(event.target.value);
// this.setState({ value: event.target.value });
};
render() {
const Home = () => {
return (
<Provider store={store}>
<div className="categories">
<Select
options={this.state.options}
onChange={this.stateChange}
/>
</div>
Select'sonChangeprop actually take? It might not be an event as you're expecting. 2) If you're definingstateChangeas an arrow function. you don't need to bind it tothisin the constructor. That actually does nothing due to how arrow functions are scoped.