Home > Backend Development > PHP Tutorial > javascript - React es6 binding event problem

javascript - React es6 binding event problem

WBOY
Release: 2016-07-06 13:52:55
Original
1403 people have browsed it

javascript - React es6 binding event problem
Using react redux to do a project, I encountered an event binding problem. Loop is a traversal method, such as loop (ajaxdata),

javascript - React es6 binding event problem

But I can’t get the id of this item, please help

Reply content:

javascript - React es6 binding event problem
Using react redux to do a project, I encountered an event binding problem. Loop is a traversal method, such as loop (ajaxdata),

javascript - React es6 binding event problem

But I can’t get the id of this item, please help

<code>onClick={() => {alert(item.id)}}</code>
Copy after login

The item in

onClick should be the parameter in the function declaration, not the actual parameter passed in. As a result, the item.id in the function body is actually the member value of the parameter. Remove the item parameter or change it to a variable other than item. Try
It is recommended to learn more about arrow functions

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template