Entity lifecycle in Resium's Viewer component

Hi,

I am using Resium (a ReactJS wrapper for CesiumJS) and I am facing what seems to be an issue with the way the entities collection is managed by the Viewer.

In a parent component I am updating a list of points of interest (POI) containing lon/lat coordinates and an id. I am passing this list of POIs as a prop to a child component wrapping a resium’s Viewer component.

In the child component, I am dynamically building a list of Entity component from the list of POIs. I have a useEffect hook which calls cesium’s viewer flyTo method to the first entity every time the list of POI changes.

Expected

The viewer should fly to the first created entity every time the POI prop changes.

Observed

Some time, the viewer does not fly to the first entity.

Investigations

While debugging the calls stack, it seems that at the moment the flyTo method is being called in the useEffect callback, the viewer’s DataSourceDisplay instance does not contain the new Entities collection when the getBoundingSphere method is being called on it. This result in a FAILED state for the entity bounding sphere which makes updateZoomTarget return early.

I have raised it on resium’s github issues and opened a SO thread about it.

I have deployed a simple demo for repro here
And the source are available here