-
Notifications
You must be signed in to change notification settings - Fork 35
fix: datasource context provider will now cleanup when being unmounted #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: datasource context provider will now cleanup when being unmounted #126
Conversation
Thank you @rvdkooy! I was testing this PR with react-azure-maps-playground without strict mode and I got errors like the following while navigating between different examples. You're right, there are other cleanup issues and they might need to be fixed altogether at once.
|
…he same datasource
hi @yulinscottkang
In my latest commit, i've added some logic where the Also had to do some updates on the playground see: |
Thanks @rvdkooy, LGTM! |
@yulinscottkang my latest commits should be fine and ready for review |
getLayersDependingOnDatasource(dref).forEach((l) => { | ||
mref.layers.remove(l.getId() ? l.getId() : l) | ||
}) | ||
mref.sources.remove(dref) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rvdkooy, this is great!
Do you mind apply the same fix to AzureMapVectorTileSourceProvider.tsx
as well? It can be tested with react-azure-maps-playground under http://localhost:3000/custom-traffic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, wasn't able to have a look at it for a while.
I also fixed it in AzureMapVectorTileSourceProvider
Gr,
R
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and LGTM! Thank you @rvdkooy.
<AzureMapDataSourceProvider />
does not work well with React.StrictModeStrict mode will render, unmount and rerender again to find common issues see: https://reactjs.org/docs/strict-mode.html
When Strict mode is enabled, it will throw the following error:
Uncaught Error: 'datasource-id' is already added to the map
(map will not render anymore)This PR fixes this issue by doing a cleanup when
<AzureMapDataSourceProvider />
is being unmounted.note: This PR does not fix any other cleanup issues in other components, so there could be more!