Class component event bindingimport React from 'react'; import ReactDOM from 'react-dom'; class App extends React.Component { handleClick() { console.log(111); } render() { return (<button onClick={this.handleClick} > Click me</button >) } } ReactDOM.render(<App />, document.getElementById('root')) Function component event bindingimport React from 'react'; import ReactDOM from 'react-dom'; function App() { function handleClick() { console.log(111); } // There is no this in the function component, so just write the function name without adding this. return (<button onClick={handleClick}>Click me</button>) } ReactDOM.render(<App />, document.getElementById('root')) SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: 9 Practical CSS Properties Web Front-end Developers Must Know
>>: MySQL series tutorials for beginners
First, let's talk about why we use provide/in...
This article uses an example to describe how to c...
MySQL's MyISAM and InnoDB engines both use B+...
1. Execute SQL to view select @@session.sql_mode;...
Environment Preparation Docker environment MySQL ...
Learned ConcurrentHashMap but don’t know how to a...
DetachKeyPair Unbind SSH key pairs from one or mo...
In fact, this is very simple. We add an a tag to ...
Preface Today, a developer gave me feedback that ...
When building a B/S system interface, you often en...
When the resolution of the login interface is par...
This article uses an example to illustrate the me...
The pagination component is a common component in...
Table of contents Preface Problem: Large file cop...
1. Introduction When a web project is published o...