我想从我的渲染方法外部返回jsx。它在没有API请求的情况下工作,但只要添加请求并添加回调,我就无法返回jsx。我该怎么做呢? renderLocations正在我的渲染方法中调用。如何从具有回调的外部函数返回jsx?
renderLocations() {
this.Geo((coord) => {
return this.state.location.map((location, index) => {
return (
<div>
{coord}
</div>
);
})
})
}
难道不明显吗?你从'renderLocations'方法返回什么?在回调中返回不会从外部范围返回。 –