iTwin / viewer

Monorepo that contains the iTwin Viewer npm packages and their related packages
MIT License
25 stars 16 forks source link

Fix Viewer rerendering on sibling component change #251

Closed Jake-Screen closed 1 year ago

Jake-Screen commented 1 year ago

In the change from v3.2.2 to v3.3.0 of viewer-react , a bug with the viewer was introduced. When there was a sibling component to the viewer in an viewer application, updating the state of the sibling component would cause the viewer to fully rerender. This was found to be caused by a change to the dependencies of a hook in the IModelLoader.

The change that caused the bug was changing the dependencies of the getModelConnection from checking only the iTwinId, iModelId, changeSetId, and filePath to checking all of the the viewer's props. When the parent of both the viewer and its sibling would rerender due to a change in the sibling, items like ui providers would be created again. This changed the viewer's props, causing the hook to trigger and reset the imodel connection.