handleChangeSingle
和pushToarray
中进行调试,但没有帮助handleChangeSingle
和pushToarray
中看到这些值https://codesandbox.io/s/material-demo-o8wb4
//const handleChangeSingle = value => {
const handleChangeSingle = value => name => event => => {
setSingle(value);
setValues({ ...values, [name]: event.target.value });
console.log("handleChange----->", values);
};
function pushToarray(e) {
console.log("handleChange pushToarray----->", e);
if (e.key === "Enter") {
e.preventDefault();
setValues({ tags: [...values.tags, e.target.value], tag: "" });
setAnchorEl(null);
}
}
<Select
classes={classes}
styles={selectStyles}
inputId="react-select-single"
TextFieldProps={{
label: "Country",
InputLabelProps: {
htmlFor: "react-select-single",
shrink: true
}
}}
placeholder="Search a country (start with a)"
options={suggestions}
components={components}
value={single}
onChange={handleChangeSingle}
onKeyDown={e => pushToarray(e)}
/>