我有函数,我想将ID传递给componentDidMount。我努力尝试,但没有找到任何解决方案来实现我的目标。实际上我有renderEvent()函数,在这个函数中我有customerID,我想在componentdidmount中使用此ID进行API调用。有人可以帮我解决这个问题吗
码
componentDidMount() {
.../ want to access CustomerID here
}
renderEvent() {
<p>Customer Name : {slotInfo.customerId}
}
想要将此客户ID发送到up componentdidmount函数
最佳答案
在这里,但是进一步的代码将取决于,您从那里获得slotInfo.
componentDidMount() {
const custId = getCustomerId()
}
getCustomerId=()=> slotInfo.customerId
renderEvent() {
return
<p>Customer Name : {getCustomerId()}
}