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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744708759a4589213.html
评论列表(0条)