Using react redux to do a project, I encountered an event binding problem. Loop is a traversal method, such as loop (ajaxdata),
But I can’t get the id of this item, please help
Using react redux to do a project, I encountered an event binding problem. Loop is a traversal method, such as loop (ajaxdata),
But I can’t get the id of this item, please help
<code>onClick={() => {alert(item.id)}}</code>
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