From f6f5a0a94c860fc30e18ca493958c9f1fbc4e559 Mon Sep 17 00:00:00 2001 From: rot1024 Date: Wed, 3 Jul 2019 15:35:22 +0900 Subject: [PATCH] fix: cannot update Label props (close #92) --- src/Label/Label.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Label/Label.ts b/src/Label/Label.ts index 0001741be..abcb9542b 100644 --- a/src/Label/Label.ts +++ b/src/Label/Label.ts @@ -46,7 +46,7 @@ export interface LabelCesiumProps { export interface LabelProps extends LabelCesiumProps, EventProps {} export interface LabelContext { - labelCollection?: Cesium.LabelCollection; + labelCollection: Cesium.LabelCollection; __RESIUM_EVENT_MANAGER?: EventManager; } @@ -79,15 +79,12 @@ const cesiumProps: (keyof LabelCesiumProps)[] = [ const Label = createCesiumComponent({ name: "Label", create(cprops, props, context) { - return new (Cesium.Label as any)(cprops, context.labelCollection); + return context.labelCollection.add(cprops); }, mount(element, context, props) { if (context.__RESIUM_EVENT_MANAGER) { context.__RESIUM_EVENT_MANAGER.setEvents(element, props); } - if (context.labelCollection) { - context.labelCollection.add(element); - } }, unmount(element, context) { if (context.__RESIUM_EVENT_MANAGER) {