我想在一些嵌入的 html 中调用一个函数。我尝试了以下但未调用该函数。这会是在渲染方法中调用函数的错误方式吗?
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>
);
}
}
原文由 lost9123193 发布,翻译遵循 CC BY-SA 4.0 许可协议
要调用该函数,您必须添加
()