The fix would be to copy the camera state if an instance exists already, and set it to the new instance's camera right after it's created. Something like:
const cameraState = instance ? instance.getCamera().getState() : null;
// [...] existing code that remounts the instance
if (cameraState) instance.getCamera().setState(cameraState);
When a new
graph
prop value is given to someSigmaContainer
instance, the camera is reset. I was expecting the camera to remain the same.The reason is visible here: https://github.com/sim51/react-sigma/blob/9b5572955a278debc9da2201717e84906b7adfec/project/packages/core/src/components/SigmaContainer.tsx#L82-L86
The fix would be to copy the camera state if an instance exists already, and set it to the new instance's camera right after it's created. Something like: