小编rof*_*ter的帖子

onClick 属性和函数是否暴露在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)

预期行为:

  1. 用户单击选项(在下拉列表中)
  2. 反应选择 100 毫秒内不应执行任何操作
  3. 100 毫秒后,react-select 完成了他的工作

我已经在和组件上尝试过使用 props selectOptiononChange、 和,但它不起作用。onClickSelectcomponents.Options

reactjs react-select

1
推荐指数
1
解决办法
6938
查看次数

标签 统计

react-select ×1

reactjs ×1