0
몇 가지 매개 변수로 실행하는 onClick 이벤트가 있습니다. 이 paramt 현재 이벤트에 추가하는 방법? 나는 다음 뷰 (모두하지 nesseccary 코드 제거) 한이 event.stopPropagation()
전송 이벤트를 onClick에 반박하십시오.
내 코드와 같은 기능 somethig에에하고 싶은 :
이import React from 'react';
export default class AllCarWashTable extends React.Component{
constructor(props) {
super(props);
this.removeCarWashHandler = this.removeCarWashHandler.bind(this);
...
};
removeCarWashHandler(e, name, id){
e.stopPropagation();
...
}
generateRows() {
const removeCarWashHandler = this.removeCarWashHandler
...
return data.map(function(item) {
var cells = cols.map(function(colData) {
...
<button type="button"
onClick={()=> removeCarWashHandler(item['name'], item['id'])}>
ButtonName
</button>
...
});
}
}
Currenly 내 코드는 예외로 연결 : TypeError: Cannot read property 'stopPropagation' of undefined
어떻게이 문제를 해결하려면?
onClick={e => removeCarWashHandler(e, item['name'], item['id'])}
네, 당신은 절대적으로 옳다 : –
걱정하지 않아도 문제가 해결되면 내 대답을 올바르게 표시 할 수 있습니다. –