admin管理员组

文章数量:1390610

I am upgrading version of react-select to 5.10.0 and onClick event on custom clear icon is stopped working, previously *react select 5.2.2 it was working.

Here I added codesanbox

<Select
  closeMenuOnSelect={false}
  components={{ ClearIndicator }}
  styles={{ clearIndicator: ClearIndicatorStyles }}
  defaultValue={[colourOptions[4], colourOptions[5]]}
  isMulti
  options={colourOptions}
/>
 
const ClearIndicator = (props: ClearIndicatorProps<ColourOption, true>) => {
  const {
        children = <CustomClearText />,
       getStyles,
       innerProps: { ref, ...restInnerProps },
      } = props;
    return (
<div
  {...restInnerProps}
  ref={ref}
  onClick={handleClick}
  style={getStyles("clearIndicator", props) as CSSProperties}
>
  <div style={{ padding: "0px 5px" }}>{children}</div>
</div>
)};


const handleClick = (e) => { // this is not executing
     e.preventDefault();
     console.log("handle some logic");
};

Thanks in advance.

本文标签: