I want to set up an event listener in a component that will go away when the component is destroyed. Is this the correct way to do that?
this.ownWhileRendered(connect(document, 'click', this.handleDocClick.bind(this)));
connect
-> returns a destroyable (https://backdraftjs.org/docs.html#bd-core.functions.connect)
ownWhileRendered
-> Ensures Destroyable instances are destroyed when the instance is unrendered (https://backdraftjs.org/docs.html#bd-core.classes.Component.ownWhileRendered)
So does that seem correct?
If you wish to make the listener go away:
when the component is destroyed, then
when the component is unrendered, then