reactjs - onClick "Type 'void' is not assignable to type '((event: MouseEvent) => void) | undefined'."
问题描述
const thing = () => {
let selectedPage = "hello"
const addCduPageButton = () => {
return (
<div>
<button onClick={addCduPage(selectedPage)}>Add Page</button>
</div>
)
}
const addCduPage = (value: string) => {
console.log(value)
}
return(
<div>
{addCduPageButton}
</div>
)
}
export default thing;
https://i.stack.imgur.com/NJN1U.png
Type 'void' is not assignable to type '((event: MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined'.
I am not understanding the issue with the onClick property of the button.
解决方案
推荐阅读
- python - 在 python gdb 脚本中索引 c++ 向量
- reactjs - 在我的应用程序中获取用于设置 MapView 的用户坐标会生成未定义的值
- java - 用于异步处理的 Akka?
- c - 为什么 getline 在将 `-wrap=malloc` 传递给链接器时调用 glibc 的 malloc 而不是 __wrap_malloc?
- multithreading - 如何在 Rust 的 for 循环中添加线程?
- c# - MyClassLibrary.dll 看不到我的 Assembly.resources.dll
- c - AT-Commands ESP8266 01: AT+CIPSTART: How to fix response Link type Error / Can't connect with TCP
- excel - 从 7 个输入文件在一个 Excel 文件“报告”中提供多张工作表
- javascript - 如何在 Vuejs v-for 中迭代 GraphQL 聚合节点
- python - 如何在 pandas 中合并和格式化包含 int 数据类型的多个列?