TypeScript: CommonProps['setValue']
doesn't match Select.tsx
's setValue
#4877
-
After upgrading to 5.1, I have noticed that the type definition of // CommonProps['setValue']
setValue: (
newValue: OnChangeValue<Option, IsMulti>,
action: SetValueAction,
option: Option
) => void;
// Implementation inside Select.tsx
setValue = (
newValue: OnChangeValue<Option, IsMulti>,
action: SetValueAction,
option?: Option
) => { Notice how the third argument Is this intended? import Select, { MenuListProps } from 'react-select';
<Select components={{ MenuList }} {...otherPropsHere} />
function MenuList(props: MenuListProps) {
const { setValue } = props;
// Somewhere down the line:
setValue(newValue, 'select-option', undefined as any);
} If this is not intended behaviour, I'd be happy to try and fix this in a PR. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks, good catch! It should be optional. The intention is that for multi-select the option will be passed, but it won't be for single-select. If you could make a PR that would be great. |
Beta Was this translation helpful? Give feedback.
Thanks, good catch! It should be optional. The intention is that for multi-select the option will be passed, but it won't be for single-select. If you could make a PR that would be great.