Cannot update/toggle Rectangle Image Entity Layer (Cesium + React)

Hello,

I’m working on a React application incorporating CesiumJS for mapping functionalities. I’ve implemented methods for toggling various layers on and off within the application. However, despite trying different approaches, I’m encountering an issue where the updates to the layers aren’t reflected on the map. And, I’m not using Resium. Could someone provide guidance on the correct approach to resolve this issue? Any insights or suggestions would be greatly appreciated. Thank you.

    const updateSimulationLayer = (viewer, simulationLayerData) => {
        if (viewer && simulationLayerData) {
            const dataSourceName = "raster-layers";
            console.log("Updating simulation layer...");
            // removeOldDataSourcesWithName(viewer, dataSourceName);
            const oldEntity = viewer.entities.getById("raster-layer");
            console.log("Old raster layer: ", oldEntity);
            if (!oldEntity) {
                const rasterSuperImposeLayer = new Cesium.Entity({
                    id: "raster-layer",
                    name: "Raster Layer",
                    rectangle: {
                        coordinates: Cesium.Rectangle.fromDegrees(
                            EPSG3857_BOUNDS[0][0], // West
                            EPSG3857_BOUNDS[3][1], // South
                            EPSG3857_BOUNDS[2][0], // East
                            EPSG3857_BOUNDS[1][1]  // North
                        ),
                        material: new Cesium.ImageMaterialProperty({
                            image: new Cesium.ConstantProperty(simulationLayerData.toString()),
                            transparent: true,
                            alpha: 0.4,
                        }),
                        clampToGround: true,
                    },
                });
                console.log("Adding new raster layer: ", rasterSuperImposeLayer)
                viewer.entities.add(rasterSuperImposeLayer);
                viewer.scene.requestRender();
            } else {
                console.log("Raster layer already exists: ", oldEntity);
                console.log("Old", oldEntity.rectangle.material.image);
                oldEntity.rectangle.material.image = new Cesium.ConstantProperty(simulationLayerData.toString());
                console.log("New", oldEntity.rectangle.material.image);
                viewer.scene.requestRender();
                console.log(viewer.entities);
            }
        }
    }