Closed loveky closed 4 years ago
以 Polygon 为例,在 constructor 执行 13ms 之后调用initMapPolygon进而调用onInstanceCreated并不能保证高阶组件中的 ref 回调已经执行,因此执行 onInstanceCreated 时,this.myMapComponent 可能为 null. 因此考虑增加 this.myMapComponent 是否为空的判断,如果为空,则在 didMount 中执行 onInstanceCreated (ref 回调会保证在 didMount 之前执行)
@ioslh 帮忙review一下吧
以 Polygon 为例,在 constructor 执行 13ms 之后调用initMapPolygon进而调用onInstanceCreated并不能保证高阶组件中的 ref 回调已经执行,因此执行 onInstanceCreated 时,this.myMapComponent 可能为 null. 因此考虑增加 this.myMapComponent 是否为空的判断,如果为空,则在 didMount 中执行 onInstanceCreated (ref 回调会保证在 didMount 之前执行)