Unmounting a Decoration Widget created with React

I am using the (view, getPos) => … form of the toDom param in Decoration.Widget(). In that function, I am using ReactDOM.Render(). It all works great, except it doesn’t clean up when destroyed. What would be the proper way to detect widget destruction in such a case in order to call react-dom’s unmountComponentAtNode() to clean up?

For now, I am going to see about solving this feature with a NodeView which gives a bit more fidelity to the DOM lifecycle than does a widget.

I guess adding support for a destroy methods to widgets should be possible (it’ll work much like the node view destroy currently works). If you want to submit a patch that adds that, I’ll gladly take a look.

Sure, I can take a crack at that.