我有一个选择框并将数据设置为onChange
事件的状态。请看下面的代码。任何人都可以帮助我在 React 测试库中为此onChange
事件编写案例。
const [optionValue, setOptionValue] = useState({ value: '', label: '' })
const handleOnChange = (option: OptionType): void => setOptionValue(option)
<Select name={title} id={title} placeholder="Choose an Option" options={setOptionsData} defaultOption={optionValue} onChange={e => { handleOnChange(e) }} data-test="options" />