下面的代码仅返回字符串文字。我在某处读到模板字符串内的 Async-Await 需要具有顶级等待,但在我的情况下如何获得顶级等待?
<Autocomplete
renderOption={(props, option) =>
<li {...props}>
{`${ async () => await getGeocode({placeId: option.place_id})
.then(results => getZipCode(results[0], true))()}
`}
</li> }
/>
我认为你应该从字符串文字中提取异步请求
可能会创建一个名为 Option 的新组件,它将 api 调用所需的参数作为 Props 并在 useEffect 中进行 api 调用