我遇到了阴影名称:'props'(无阴影变量)tslint(1)



我是React的新手,遇到来自tslint的警告,上面写着"阴影名称:'props'(没有阴影变量(tslint(1("。我真的解决不了这个问题,所以我真的需要你的帮助。

return (
<DropdownMenuPortal
children={children}
anchorEl={anchorEl}
container={document.body}
isOpen={menuIsOpen}
/>
);
},
ValueContainer: this.ValueContainer,
MultiValue: this.MultiValue,
SingleValue: this.SingleValue,
Placeholder: this.Placeholder,
Control: this.Control,
**//Here I have that issue**
Menu: (**props**: MenuProps<OptionType> & { innerProps: { onMouseDown(): void } }) => {
const {
selectProps: { options, filterOption, inputValue },
children,
getValue,
setValue,
innerProps: { onMouseDown },
} = props;
const value = getValue() as OptionsType<OptionType>;
const showSelectAllBtn = value.length < options.length;
const showClearAllBtn = !!value.length;
const onSelectAll = () => {
const filteredOptions = options.filter(option =>
filterOption(option as any, inputValue)
);
setValue([...value, ...filteredOptions], setValueAction);
};

出现警告是因为您多次重新定义了同一变量。

如果你真的需要关闭此警告,请将其添加到tslint规则中:

"rules": {
"no-shadowed-variable": false
}

最新更新