我的组件需要显示当前位置。获取地理位置的调用是异步的。要尽快显示坐标,我会在创建组件时(在ctor中)发出调用以获取位置。但是,当异步调用在安装组件之前完成时,我收到错误:
Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the component.
组件安装时设置状态的正确方法是什么?