rof*_*ter 1 reactjs react-select
我想延迟react-select的选项元素上的onClick事件。
例子:
import React from "react";
import { components } from "react-select";
const Option = props => {
const { label, data, onClick } = props;
return (
<components.Option
{...props}
onClick={() => {
setTimeout(onClick, 100);
}}>
<div>Some custom stuff here</div>
</components.Option>
);
};
export default Option;
Run Code Online (Sandbox Code Playgroud)
预期行为:
我已经在和组件上尝试过使用 props selectOption、onChange、 和,但它不起作用。onClickSelectcomponents.Options
找到了:)
不确定它是否正确,但它有效。
const { innerProps } = props;
const { onClick } = innerProps;
props.innerProps.onClick = e => {
setTimeout(() => {
onClick(e);
}, 100);
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6938 次 |
| 最近记录: |