17
我想調用某個嵌入式html中的函數。我嘗試了以下但該函數未被調用。這是在render方法中調用函數的不正確方式嗎?如何調用React/Jsx中的渲染函數
import React, { Component, PropTypes } from 'react';
export default class PatientTable extends Component {
constructor(props) {
super(props);
this.state = {
checking:false
};
this.renderIcon = this.renderIcon.bind(this);
}
renderIcon(){
console.log("came here")
return(
<div>Function called</div>
)
}
render() {
return (
<div className="patient-container">
{this.renderIcon}
</div>
);
}
}
它取決於您的需要,您可以使用'this.renderIcon()'或綁定'this.renderIcon.bind(this)'。 這是正確的嗎?有人寫下了。 – Siddharth
討厭新事物,失蹤():S 謝謝:) – OmarBizreh