Вот мой <select>
компонент:Как передать несколько параметров через компонент React <select>?
handleSelect: function(myVar, anotherVar) {
// Do I need to somehow use event.preventDefault(); here?
// I want to be able to do something with myVar and anotherVar here...
// ...but it seems I cannot access the event and the value of anotherVar
// at the same time...at least not this way.
},
render: function() {
let myVar = "Yes",
anotherVar = "Another value",
id = 1;
return (
<select defaultValue={myvar} onChange={this.handleChange.bind(this, anotherVar}>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
);
}
Я хочу, чтобы иметь возможность работать с myVar
(на основе стоимости <select>
входных), и anotherVar
в моей handleSelect
функции. Как правильно передать значение элемента <select>
в этом случае?