Skip to content

Commit

Permalink
fix: change imageryProvider to readonly (#665)
Browse files Browse the repository at this point in the history
* Fix ImageryLayer readonly imageryProvider prop

Fixes lack of recreation on imageryProvider prop update by adding it to
the cesiumReadonlyProps array, which is where it belongs according to
the Cesium and Resium documentation.

Addresses #664

* Remove unnecessary type definition

---------

Co-authored-by: keiya sasaki <[email protected]>
  • Loading branch information
TheMrCam and keiya01 authored Jul 9, 2024
1 parent 0fc7823 commit 3f790ea
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/ImageryLayer/ImageryLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ export type Target = Merge<CesiumImageryLayer, ConstructorOptions2<typeof Cesium

export type ImageryLayerCesiumProps = PickCesiumProps<Target, typeof cesiumProps>;

export type ImageryLayerCesiumReadonlyProps = PickCesiumProps<Target, typeof cesiumReadonlyProps>;

export type ImageryLayerOtherProps = {
export type ImageryLayerCesiumReadonlyProps = Omit<
PickCesiumProps<Target, typeof cesiumReadonlyProps>,
"imageryProvider"
> & {
imageryProvider: ImageryProvider | Promise<ImageryProvider>;
};

export type ImageryLayerProps = ImageryLayerCesiumProps &
ImageryLayerCesiumReadonlyProps &
ImageryLayerOtherProps;
ImageryLayerCesiumReadonlyProps;

const cesiumProps = [
"alpha",
Expand All @@ -83,10 +83,9 @@ const cesiumReadonlyProps = [
"minimumTerrainLevel",
"maximumTerrainLevel",
"readyEvent",
"imageryProvider",
] as const;

const otherProps = ["imageryProvider"] as const;

const ImageryLayer = createCesiumComponent<CesiumImageryLayer, ImageryLayerProps>({
name: "ImageryLayer",
async create(context, props) {
Expand Down Expand Up @@ -127,7 +126,6 @@ const ImageryLayer = createCesiumComponent<CesiumImageryLayer, ImageryLayerProps
},
cesiumProps,
cesiumReadonlyProps,
otherProps,
});

export default ImageryLayer;

0 comments on commit 3f790ea

Please sign in to comment.