reactjs - 如何在 tsx 中将道具传递给孩子?
问题描述
当我将道具传递给孩子时,我有一个错误“属性'isClicked'不存在于类型'IntrinsicAttributes & IntrinsicClassAttributes”我写了“isClicked?:布尔”。我还应该做什么?
export interface DropDownProperties extends ComponentBaseProperties {
multiSelect?: boolean;
IconTextColor?:string;
isClicked?: boolean;
}
export interface DropDownState extends ComponentBaseState {
dropDownOptions: DropDownItem[];
isOpen: boolean;
results: string[];
isClicked?: boolean;
}
export default class DropDown extends ComponentBase<
DropDownProperties,
DropDownState
> { return ( <DropDownItem
iconName={option.iconName}
value={option.value}
displayValue={option.displayValue ? true : false}
key={option.name}
onClick={(e) => this.optionSelected()}
isClicked={this.state.isOpen}
>
{option.props.children}
</DropDownItem>
))}
</ul>
);
}
};
解决方案
如果您在组件中使用连接,则使用以下代码应该可以解决问题。
export default connect<{}, {}, Props>(..........)
这里connect
有 3 个参数,第三个参数是 interface Props
,它有你想要输入的变量。
推荐阅读
- python - 根据组过滤 DataFrame 行
- sql - 如何在 Oracle SQL 中使用 REGEXP_REPLACE 根据多个条件准确识别要替换的单词?
- python - 调用日志配置函数后“'NoneType'对象没有属性'info'”
- kubernetes - 命名空间中所有部署的 kubectl 部署状态
- c - 在 aix 中使用 free() 函数时(静态区域 free())
- c# - 在 dynamodb c# 中使用 GetRemaining() 无法更快地加载数据?
- node.js - 如何在 GitLabCI 的 node:10 容器中执行 docker 命令
- spring - 如何解决使用 Maven 导入 spring 应用程序的问题?
- php - 从多维数组中获取数组值
- actionscript-3 - 你能告诉我我的错吗?这是关于如果嵌套(flash cs6 as3)