mongodb-js / connect-backbone-to-react

Connect Backbone Models and Collections to React.
https://www.npmjs.com/package/connect-backbone-to-react
Apache License 2.0
27 stars 5 forks source link

Don't call createNewProps if component unmounted within event handler #5

Closed hswolff closed 7 years ago

hswolff commented 7 years ago

"all" event handlers are triggered after individual event handlers. That is to say, if you trigger "foo" the sequence of event handlers called is: "foo" -> all event handlers (which can include additional triggers) -> "all" -> event handlers. When you .off('all') within an event handler Backbone reassigns the "all" array of handlers such that when you get to triggering the "all" event handlers that array has not been updated. This is the line that reassigns that array: https://github.com/jashkenas/backbone/blob/bd50e2e4a4af5c09bc490185aab215794d42258b/backbone.js#L296 So that when you get here https://github.com/jashkenas/backbone/blob/bd50e2e4a4af5c09bc490185aab215794d42258b/backbone.js#L357 the "allEvents" value is stale.