Closed CaptainCed closed 2 years ago
I think you need to guard the view.ui.remove()
call like:
return function cleanup() {
if (_expandWidget) {
props.view.ui.remove(_expandWidget);
}
};
If that doesn't work, you could try not putting the expand widget in state. What if you just did:
React.useEffect(() => {
let expandWidget: __esri.Expand;
loadModules(['esri/widgets/Expand']).then(([Expand]) => {
expandWidget = new Expand({
view: props.view,
content: ref.current,
expandIconClass: 'esri-icon-edit',
collapseIconClass: '',
expanded: true,
group: props.group,
});
props.view.ui.add(expandWidget, {
position: props.position,
index: props.index,
});
setExpandWidget(expandWidget);
});
return function cleanup() {
if (expandWidget) {
props.view.ui.remove(expandWidget);
}
};
}, []);
Hello,
My application owns a menu that allows to add and remove expand widgets on the map view. The list of widgets is stored in Redux and my React main class reads this list before injecting it into the react-argis Map class. The problem is when I try to remove a widget from the map I get the following error:
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Here is a sample of the class i try to remove:
And the render method of my React class: