BackgroundIn a list like the one below, clicking the Delete button requires the delete operation to be performed List generation: { title: 'Operation', dataIndex: 'rowguid', key: 'rowguid', render: (text, record) => ( <Space size="middle"> <Button type="primary" size="small" >Modify</Button> <Button type="danger" size="small" >Delete</Button> </Space> ) } I need to add an event when rendering and generating the delete button, and call it when it is clicked, and also pass parameters. This parameter I started by writing: But the problem is that the delByGuid function is executed when the page is loaded, and the output of our console is: Not only that, when I clicked the delete button, the function was not executed. It seems that this is not allowed. question:1. Executed when the page is rendered 2. Click the button, onclick is not executed Solution:{ title: 'Operation', dataIndex: 'rowguid', key: 'rowguid', render: (text, record) => ( <Space size="middle"> <Button type="primary" size="small" >Modify</Button> <Button type="danger" size="small" onClick={(e)=>delByGuid(text)}>Delete</Button> </Space> ) } onClick={(e)=>delByGuid(text)} This solves the problem. It doesn't work when the page is loaded, but it can be called when it is clicked. This is the end of this article about React onClick passing parameters. For more relevant React onClick passing parameters content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Implementation of docker-compose deployment project based on MySQL8
>>: Detailed deployment steps for MySQL MHA high availability configuration and failover
A few days ago, I exchanged some knowledge about ...
I believe that people who have experience with Re...
Table of contents posgresql backup/restore mysql ...
Table of contents Overview 1. Application-level m...
Table of contents vite function Use Environment B...
What is an index? An index is a data structure th...
Summarize This article ends here. I hope it can b...
Table of contents 【Function Background】 [Raw SQL]...
Table of contents 1. Generate a certificate 2. En...
By default, the width and height of the table are...
Preface When docker run creates and runs a contai...
The cascading drop-down menu developed in this ex...
Table of contents Introduction to stored procedur...
Table of contents Container Hierarchy The process...
1. dhtmlxTree dHTMLxTree is a feature-rich Tree M...