Azure / Azure/react-azure-maps

Uncaught error 'source-id' is already added to the map

Open
#94 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
TypeScript
Stars
58
Forks
43
PR merge metrics
No merged PRs in 30d

Description

`Uncaught error 'source-id' is already added to the map`
I can trigger this error by toggling a rendered data source and layer. For example by toggling the value of showLayer off and on again:

```
const { showLayer } = props;

return (
{showLayer
?


: null
}
)

```
It looks like data source cleanup is not being done by react-azure-maps?

If I manually remove the source and layer in a cleanup useEffect:
```
useEffect(() => {
return () => {
map.layers.remove('layer'id');
map.sources.remove('source-id);
}
}, []);
```
It fixes the error, but then I get further errors from the wrapper as it tries to remove the layers itself:
`Error on remove layer Error: The layer 'layer-id' has not been added to the map and cannot be removed`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.