View resets to default when a new mode is selected in 3D scatter plot

Using React Plotlyjs, if the view is changed by rotation or zoom and the user then clicks on pan button in the modebar, the view resets to default and previous transformations are undone. Same thing happens for rotation and panning as well. Any idea what could be going wrong here?