I have a react component created as a const and with props.
I also have a function see: selectChanged() {} is another file which is returning undefined when I change the select value.
Here is the component code:
...
const myComponent = (props) => <div id="myid">
<form onSubmit={props.onSubmit} className="gs-form">
<div className="label">MySelect</div>
<select
id="myselect"
value=""
onChange={props.selectChanged}>
<option value="one" defaultValue>one</option>
<option value="two">two</option>
<option value="three">three</option>
</select>
</div>
</form>
</div>;
export default myComponent;
And the data is passed to this:
selectChanged(value) {
console.info(value);
}
The problem is that it keeps showing undefined what I change the select value.
How can I fix this so that 'selectChanged' passes the value of the selected select ?
value="", either remove it, or use a variable and update that in onChange function, like this:value={props.selectedValue}